Skip to content

Commit c57b8ee

Browse files
authored
Merge pull request #4730 from jeromegamez/deduplicate
Deduplicate code
2 parents dc06e6d + b54e1a3 commit c57b8ee

2 files changed

Lines changed: 11 additions & 21 deletions

File tree

system/Database/Seeder.php

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -127,25 +127,16 @@ public static function faker(): ?Generator
127127
*/
128128
public function call(string $class)
129129
{
130-
if (empty($class))
130+
$class = trim($class);
131+
132+
if ($class === '')
131133
{
132134
throw new InvalidArgumentException('No seeder was specified.');
133135
}
134136

135-
$path = str_replace('.php', '', $class) . '.php';
136-
137-
// If we have namespaced class, simply try to load it.
138-
if (strpos($class, '\\') !== false)
137+
if (strpos($class, '\\') === false)
139138
{
140-
/**
141-
* @var Seeder
142-
*/
143-
$seeder = new $class($this->config);
144-
}
145-
// Otherwise, try to load the class manually.
146-
else
147-
{
148-
$path = $this->seedPath . $path;
139+
$path = $this->seedPath . str_replace('.php', '', $class) . '.php';
149140

150141
if (! is_file($path))
151142
{
@@ -160,14 +151,13 @@ public function call(string $class)
160151
{
161152
require_once $path;
162153
}
163-
164-
/**
165-
* @var Seeder
166-
*/
167-
$seeder = new $class($this->config);
168154
// @codeCoverageIgnoreEnd
169155
}
170156

157+
/**
158+
* @var Seeder
159+
*/
160+
$seeder = new $class($this->config);
171161
$seeder->setSilent($this->silent)->run();
172162

173163
unset($seeder);

system/Format/XMLFormatter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ protected function arrayToXML(array $data, &$output)
6363
{
6464
foreach ($data as $key => $value)
6565
{
66+
$key = $this->normalizeXMLTag($key);
67+
6668
if (is_array($value))
6769
{
68-
$key = $this->normalizeXMLTag($key);
6970
$subnode = $output->addChild("$key");
7071
$this->arrayToXML($value, $subnode);
7172
}
7273
else
7374
{
74-
$key = $this->normalizeXMLTag($key);
7575
$output->addChild("$key", htmlspecialchars("$value"));
7676
}
7777
}

0 commit comments

Comments
 (0)