Skip to content

Commit 4d7d154

Browse files
committed
Updated param names
1 parent 14a9d24 commit 4d7d154

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

src/Container.php

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,68 +23,68 @@ class Container implements ContainerInterface
2323

2424
public function __construct(array $definitions = [])
2525
{
26-
foreach ($definitions as $name => $object) {
27-
$this->set($name, $object);
26+
foreach ($definitions as $id => $object) {
27+
$this->set($id, $object);
2828
}
2929
}
3030

31-
protected function set(string $name, $object): void
31+
protected function set(string $id, $object): void
3232
{
33-
unset($this->entries[$name], $this->factories[$name]);
33+
unset($this->entries[$id], $this->factories[$id]);
3434

3535
if ($object instanceof Closure) {
3636

37-
$this->factories[$name] = $object;
37+
$this->factories[$id] = $object;
3838
} else {
39-
$this->entries[$name] = $object;
39+
$this->entries[$id] = $object;
4040
}
4141
}
4242

43-
public function with(string $name, $object): Container
43+
public function with(string $id, $object): Container
4444
{
4545
$container = clone $this;
4646

47-
$container->set($name, $object);
47+
$container->set($id, $object);
4848

4949
return $container;
5050
}
5151

52-
public function get($name)
52+
public function get(string $id)
5353
{
54-
if (isset($this->entries[$name]) || array_key_exists($name, $this->entries)) {
54+
if (isset($this->entries[$id]) || array_key_exists($id, $this->entries)) {
5555

56-
return $this->entries[$name];
56+
return $this->entries[$id];
5757
}
5858

59-
if (isset($this->factories[$name])) {
59+
if (isset($this->factories[$id])) {
6060

61-
$this->entries[$name] = $this->resolve($name);
61+
$this->entries[$id] = $this->resolve($id);
6262

63-
return $this->entries[$name];
63+
return $this->entries[$id];
6464
}
6565

66-
if ($this->canCreate($name)) {
66+
if ($this->canCreate($id)) {
6767

68-
$this->factories[$name] = $this->getClassFactory($name);
69-
$this->entries[$name] = $this->resolve($name);
68+
$this->factories[$id] = $this->getClassFactory($id);
69+
$this->entries[$id] = $this->resolve($id);
7070

71-
return $this->entries[$name];
71+
return $this->entries[$id];
7272
}
7373

74-
throw new NotFoundException("Entry for < $name > could not be resolved");
74+
throw new NotFoundException("Entry for < $id > could not be resolved");
7575
}
7676

77-
protected function resolve(string $name)
77+
protected function resolve(string $id)
7878
{
79-
if (isset($this->resolving[$name])) {
80-
throw new CircularReferenceException("Circular reference detected for < $name >");
79+
if (isset($this->resolving[$id])) {
80+
throw new CircularReferenceException("Circular reference detected for < $id >");
8181
}
8282

83-
$this->resolving[$name] = true;
83+
$this->resolving[$id] = true;
8484

85-
$object = $this->factories[$name]($this);
85+
$object = $this->factories[$id]($this);
8686

87-
unset($this->resolving[$name]);
87+
unset($this->resolving[$id]);
8888

8989
return $object;
9090
}
@@ -145,11 +145,11 @@ protected function canCreate(string $name): bool
145145
return class_exists($name);
146146
}
147147

148-
public function has($name): bool
148+
public function has(string $id): bool
149149
{
150150
if (
151-
isset($this->entries[$name]) || array_key_exists($name, $this->entries) ||
152-
isset($this->factories[$name]) || $this->canCreate($name)
151+
isset($this->entries[$id]) || array_key_exists($id, $this->entries) ||
152+
isset($this->factories[$id]) || $this->canCreate($id)
153153
) {
154154
return true;
155155
}

0 commit comments

Comments
 (0)