Skip to content
This repository was archived by the owner on Feb 6, 2020. It is now read-only.

Commit 3e9a5fb

Browse files
bakura10weierophinney
authored andcommitted
Make inner methods private
1 parent 0003d72 commit 3e9a5fb

File tree

1 file changed

+63
-63
lines changed

1 file changed

+63
-63
lines changed

src/ServiceManager.php

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -167,68 +167,6 @@ public function has($name, $checkAbstractFactories = false)
167167
return false;
168168
}
169169

170-
/**
171-
* Get a factory for the given service name
172-
*
173-
* @param string $name
174-
* @return callable
175-
* @throws ServiceNotFoundException
176-
*/
177-
protected function getFactory($name)
178-
{
179-
$factory = isset($this->factories[$name]) ? $this->factories[$name] : null;
180-
181-
if (is_string($factory)) {
182-
$this->factories[$name] = $factory = new $factory();
183-
}
184-
185-
if (is_callable($factory)) {
186-
return $factory;
187-
}
188-
189-
// Check abstract factories
190-
foreach ($this->abstractFactories as $abstractFactory) {
191-
if ($abstractFactory->canCreateServiceWithName($name)) {
192-
return $abstractFactory;
193-
}
194-
}
195-
196-
throw new ServiceNotFoundException(sprintf(
197-
'An invalid or missing factory was given for creating service "%s". Did you make sure you added the service
198-
into the service manager configuration?',
199-
$name
200-
));
201-
}
202-
203-
/**
204-
* @param string $name
205-
* @param array $options
206-
* @return object
207-
*/
208-
protected function createDelegatorFromName($name, array $options = [])
209-
{
210-
$delegatorsCount = count($this->delegators[$name]);
211-
$creationCallback = function () use ($name, $options) {
212-
// Code is inlined for performance reason, instead of abstracting the creation
213-
$factory = $this->getFactory($name);
214-
return $factory($this->creationContext, $name, $options);
215-
};
216-
217-
for ($i = 0 ; $i < $delegatorsCount ; ++$i) {
218-
$delegatorFactory = $this->delegators[$name][$i];
219-
220-
if (is_string($delegatorFactory)) {
221-
$delegatorFactory = $this->delegators[$name][$i] = new $delegatorFactory();
222-
}
223-
224-
$creationCallback = function () use ($delegatorFactory, $name, $creationCallback, $options) {
225-
return $delegatorFactory($this->creationContext, $name, $creationCallback, $options);
226-
};
227-
}
228-
229-
return $creationCallback($this->creationContext, $name, $creationCallback, $options);
230-
}
231-
232170
/**
233171
* Configure the service manager
234172
*
@@ -312,11 +250,73 @@ private function resolveAlias($alias)
312250
return $name;
313251
}
314252

253+
/**
254+
* Get a factory for the given service name
255+
*
256+
* @param string $name
257+
* @return callable
258+
* @throws ServiceNotFoundException
259+
*/
260+
private function getFactory($name)
261+
{
262+
$factory = isset($this->factories[$name]) ? $this->factories[$name] : null;
263+
264+
if (is_string($factory)) {
265+
$this->factories[$name] = $factory = new $factory();
266+
}
267+
268+
if (is_callable($factory)) {
269+
return $factory;
270+
}
271+
272+
// Check abstract factories
273+
foreach ($this->abstractFactories as $abstractFactory) {
274+
if ($abstractFactory->canCreateServiceWithName($name)) {
275+
return $abstractFactory;
276+
}
277+
}
278+
279+
throw new ServiceNotFoundException(sprintf(
280+
'An invalid or missing factory was given for creating service "%s". Did you make sure you added the service
281+
into the service manager configuration?',
282+
$name
283+
));
284+
}
285+
286+
/**
287+
* @param string $name
288+
* @param array $options
289+
* @return object
290+
*/
291+
private function createDelegatorFromName($name, array $options = [])
292+
{
293+
$delegatorsCount = count($this->delegators[$name]);
294+
$creationCallback = function () use ($name, $options) {
295+
// Code is inlined for performance reason, instead of abstracting the creation
296+
$factory = $this->getFactory($name);
297+
return $factory($this->creationContext, $name, $options);
298+
};
299+
300+
for ($i = 0 ; $i < $delegatorsCount ; ++$i) {
301+
$delegatorFactory = $this->delegators[$name][$i];
302+
303+
if (is_string($delegatorFactory)) {
304+
$delegatorFactory = $this->delegators[$name][$i] = new $delegatorFactory();
305+
}
306+
307+
$creationCallback = function () use ($delegatorFactory, $name, $creationCallback, $options) {
308+
return $delegatorFactory($this->creationContext, $name, $creationCallback, $options);
309+
};
310+
}
311+
312+
return $creationCallback($this->creationContext, $name, $creationCallback, $options);
313+
}
314+
315315
/**
316316
* Create a new instance with an already resolved name
317317
*
318318
* This is a highly performance sensitive method, do not modify if you have not benchmarked it carefully
319-
*
319+
*
320320
* @param string $resolvedName
321321
* @param array $options
322322
* @return mixed

0 commit comments

Comments
 (0)