Skip to content

Commit 5d480ed

Browse files
committed
[php74-only] Restored ordering of methods
1 parent 1b38dd6 commit 5d480ed

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

src/ObjectGraphGenerator.php

+24-24
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ public function generate(string $className): object
4949
return $this->generateObject($className);
5050
}
5151

52+
/**
53+
* @param class-string $className
54+
* @param array<mixed> $config
55+
*/
56+
public function generateWithTemporaryConfig(string $className, array $config): object
57+
{
58+
$this->temporaryRegistry = $config;
59+
$object = $this->generateObject($className);
60+
$this->temporaryRegistry = [];
61+
62+
return $object;
63+
}
64+
5265
/**
5366
* @param class-string $className
5467
* @throws ReflectionException
@@ -81,23 +94,6 @@ function (ReflectionParameter $parameter) use ($className) {
8194
: $factoryMethod->invokeArgs(null, $arguments);
8295
}
8396

84-
private function isInRegistry(string $key): bool
85-
{
86-
return array_key_exists($key, $this->temporaryRegistry) || array_key_exists($key, $this->registry);
87-
}
88-
89-
/**
90-
* @return mixed
91-
*/
92-
private function getFromRegistry(string $key)
93-
{
94-
if (isset($this->temporaryRegistry[$key])) {
95-
return $this->temporaryRegistry[$key]($this, $this->fakerInstance);
96-
}
97-
98-
return $this->registry[$key]($this, $this->fakerInstance);
99-
}
100-
10197
/**
10298
* @param ReflectionClass<object> $class
10399
*/
@@ -171,16 +167,20 @@ function () use ($argumentName, $className, $type) {
171167
}
172168
}
173169

170+
private function isInRegistry(string $key): bool
171+
{
172+
return array_key_exists($key, $this->temporaryRegistry) || array_key_exists($key, $this->registry);
173+
}
174+
174175
/**
175-
* @param class-string $className
176-
* @param array<mixed> $config
176+
* @return mixed
177177
*/
178-
public function generateWithTemporaryConfig(string $className, array $config): object
178+
private function getFromRegistry(string $key)
179179
{
180-
$this->temporaryRegistry = $config;
181-
$object = $this->generateObject($className);
182-
$this->temporaryRegistry = [];
180+
if (isset($this->temporaryRegistry[$key])) {
181+
return $this->temporaryRegistry[$key]($this, $this->fakerInstance);
182+
}
183183

184-
return $object;
184+
return $this->registry[$key]($this, $this->fakerInstance);
185185
}
186186
}

0 commit comments

Comments
 (0)