Passed
Pull Request — master (#1)
by
unknown
05:56 queued 02:55
created
src/ComponentContainer.php 2 patches
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -12,49 +12,49 @@
 block discarded – undo
12 12
 
13 13
 class ComponentContainer implements ContainerInterface
14 14
 {
15
-	/**
16
-	 * @var object[]
17
-	 */
18
-	protected $storedComponents = [];
19
-
20
-	/**
21
-	 * @param ComponentInterface $object $object
22
-	 *
23
-	 * @throws ContainerException
24
-	 */
25
-	public function add(ComponentInterface $object)
26
-	{
27
-	    $id = get_class($object);
28
-
29
-	    if ($this->has($id))
30
-	        throw new ContainerException('A class with ID ' . $id . ' already exists in this container.');
31
-
32
-		$this->storedComponents[$id] = $object;
33
-	}
34
-
35
-	/**
36
-	 * @inheritdoc
37
-	 */
38
-	public function get($id)
39
-	{
40
-		if (!is_string($id))
41
-			throw new ContainerException('Given ID must be a string');
42
-
43
-		if (!$this->has($id))
44
-			throw new NotFoundException();
45
-
46
-		return $this->storedComponents[$id];
47
-	}
48
-
49
-	/**
50
-	 * @inheritdoc
15
+    /**
16
+     * @var object[]
17
+     */
18
+    protected $storedComponents = [];
19
+
20
+    /**
21
+     * @param ComponentInterface $object $object
22
+     *
51 23
      * @throws ContainerException
52
-	 */
53
-	public function has($id)
54
-	{
55
-		if (!is_string($id))
56
-			throw new ContainerException('Given ID must be a string');
57
-
58
-		return array_key_exists($id, $this->storedComponents);
59
-	}
24
+     */
25
+    public function add(ComponentInterface $object)
26
+    {
27
+        $id = get_class($object);
28
+
29
+        if ($this->has($id))
30
+            throw new ContainerException('A class with ID ' . $id . ' already exists in this container.');
31
+
32
+        $this->storedComponents[$id] = $object;
33
+    }
34
+
35
+    /**
36
+     * @inheritdoc
37
+     */
38
+    public function get($id)
39
+    {
40
+        if (!is_string($id))
41
+            throw new ContainerException('Given ID must be a string');
42
+
43
+        if (!$this->has($id))
44
+            throw new NotFoundException();
45
+
46
+        return $this->storedComponents[$id];
47
+    }
48
+
49
+    /**
50
+     * @inheritdoc
51
+     * @throws ContainerException
52
+     */
53
+    public function has($id)
54
+    {
55
+        if (!is_string($id))
56
+            throw new ContainerException('Given ID must be a string');
57
+
58
+        return array_key_exists($id, $this->storedComponents);
59
+    }
60 60
 }
61 61
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,8 +26,9 @@  discard block
 block discarded – undo
26 26
 	{
27 27
 	    $id = get_class($object);
28 28
 
29
-	    if ($this->has($id))
30
-	        throw new ContainerException('A class with ID ' . $id . ' already exists in this container.');
29
+	    if ($this->has($id)) {
30
+	    	        throw new ContainerException('A class with ID ' . $id . ' already exists in this container.');
31
+	    }
31 32
 
32 33
 		$this->storedComponents[$id] = $object;
33 34
 	}
@@ -37,11 +38,13 @@  discard block
 block discarded – undo
37 38
 	 */
38 39
 	public function get($id)
39 40
 	{
40
-		if (!is_string($id))
41
-			throw new ContainerException('Given ID must be a string');
41
+		if (!is_string($id)) {
42
+					throw new ContainerException('Given ID must be a string');
43
+		}
42 44
 
43
-		if (!$this->has($id))
44
-			throw new NotFoundException();
45
+		if (!$this->has($id)) {
46
+					throw new NotFoundException();
47
+		}
45 48
 
46 49
 		return $this->storedComponents[$id];
47 50
 	}
@@ -52,8 +55,9 @@  discard block
 block discarded – undo
52 55
 	 */
53 56
 	public function has($id)
54 57
 	{
55
-		if (!is_string($id))
56
-			throw new ContainerException('Given ID must be a string');
58
+		if (!is_string($id)) {
59
+					throw new ContainerException('Given ID must be a string');
60
+		}
57 61
 
58 62
 		return array_key_exists($id, $this->storedComponents);
59 63
 	}
Please login to merge, or discard this patch.
src/ComponentInterface.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@
 block discarded – undo
13 13
 
14 14
 interface ComponentInterface
15 15
 {
16
-	/**
17
-	 * @param ContainerInterface $container
18
-	 *
19
-	 * @return null|object
20
-	 */
21
-	public static function fromContainer(ContainerInterface $container);
16
+    /**
17
+     * @param ContainerInterface $container
18
+     *
19
+     * @return null|object
20
+     */
21
+    public static function fromContainer(ContainerInterface $container);
22 22
 }
23 23
\ No newline at end of file
Please login to merge, or discard this patch.
src/ContainerTrait.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -13,24 +13,24 @@
 block discarded – undo
13 13
 
14 14
 trait ContainerTrait
15 15
 {
16
-	/**
17
-	 * @var ContainerInterface
18
-	 */
19
-	protected $container;
16
+    /**
17
+     * @var ContainerInterface
18
+     */
19
+    protected $container;
20 20
 
21
-	/**
22
-	 * @return ContainerInterface
23
-	 */
24
-	public function getContainer(): ContainerInterface
25
-	{
26
-		return $this->container;
27
-	}
21
+    /**
22
+     * @return ContainerInterface
23
+     */
24
+    public function getContainer(): ContainerInterface
25
+    {
26
+        return $this->container;
27
+    }
28 28
 
29
-	/**
30
-	 * @param ContainerInterface $container
31
-	 */
32
-	public function setContainer(ContainerInterface $container)
33
-	{
34
-		$this->container = $container;
35
-	}
29
+    /**
30
+     * @param ContainerInterface $container
31
+     */
32
+    public function setContainer(ContainerInterface $container)
33
+    {
34
+        $this->container = $container;
35
+    }
36 36
 }
37 37
\ No newline at end of file
Please login to merge, or discard this patch.
src/ComponentTrait.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -12,19 +12,19 @@
 block discarded – undo
12 12
 
13 13
 trait ComponentTrait
14 14
 {
15
-	/**
16
-	 * @param ContainerInterface $container
17
-	 *
18
-	 * @return static
19
-	 * @throws NotFoundException
20
-	 */
21
-	public static function fromContainer(ContainerInterface $container)
22
-	{
23
-		$obj = $container->get(__CLASS__);
15
+    /**
16
+     * @param ContainerInterface $container
17
+     *
18
+     * @return static
19
+     * @throws NotFoundException
20
+     */
21
+    public static function fromContainer(ContainerInterface $container)
22
+    {
23
+        $obj = $container->get(__CLASS__);
24 24
 
25
-		if ($obj && $obj instanceof static)
26
-			return $obj;
25
+        if ($obj && $obj instanceof static)
26
+            return $obj;
27 27
 
28
-		throw new NotFoundException();
29
-	}
28
+        throw new NotFoundException();
29
+    }
30 30
 }
31 31
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,8 +22,9 @@
 block discarded – undo
22 22
 	{
23 23
 		$obj = $container->get(__CLASS__);
24 24
 
25
-		if ($obj && $obj instanceof static)
26
-			return $obj;
25
+		if ($obj && $obj instanceof static) {
26
+					return $obj;
27
+		}
27 28
 
28 29
 		throw new NotFoundException();
29 30
 	}
Please login to merge, or discard this patch.
tests/ContainerTraitTest.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@
 block discarded – undo
13 13
 
14 14
 class ContainerTraitTest extends TestCase
15 15
 {
16
-	public function testGetSetContainerWithTrait()
17
-	{
18
-		$container = new ComponentContainer();
16
+    public function testGetSetContainerWithTrait()
17
+    {
18
+        $container = new ComponentContainer();
19 19
 
20
-		$class = new SampleContainerTraitClass();
21
-		$class->setContainer($container);
20
+        $class = new SampleContainerTraitClass();
21
+        $class->setContainer($container);
22 22
 
23
-		self::assertSame($container, $class->getContainer());
24
-	}
23
+        self::assertSame($container, $class->getContainer());
24
+    }
25 25
 }
Please login to merge, or discard this patch.
tests/SampleContainerTraitClass.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,5 +13,5 @@
 block discarded – undo
13 13
 
14 14
 class SampleContainerTraitClass
15 15
 {
16
-	use ContainerTrait;
16
+    use ContainerTrait;
17 17
 }
18 18
\ No newline at end of file
Please login to merge, or discard this patch.
tests/SampleComponent.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,5 +13,5 @@
 block discarded – undo
13 13
 
14 14
 class SampleComponent implements ComponentInterface
15 15
 {
16
-	use ComponentTrait;
16
+    use ComponentTrait;
17 17
 }
18 18
\ No newline at end of file
Please login to merge, or discard this patch.
tests/ComponentContainerTest.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -11,52 +11,52 @@
 block discarded – undo
11 11
 
12 12
 class ComponentContainerTest extends TestCase
13 13
 {
14
-	public function testContainerGet()
15
-	{
16
-		$container = new ComponentContainer();
17
-
18
-		$sampleComponent = new \Yoshi2889\Container\Tests\SampleComponent();
19
-		$container->add($sampleComponent);
20
-
21
-		$sampleComponentFromContainer = \Yoshi2889\Container\Tests\SampleComponent::fromContainer($container);
22
-
23
-		self::assertInstanceOf(\Yoshi2889\Container\Tests\SampleComponent::class, $sampleComponentFromContainer);
24
-		self::assertEquals($sampleComponent, $sampleComponentFromContainer);
25
-	}
26
-
27
-	public function testGetInvalidComponent()
28
-	{
29
-		$container = new ComponentContainer();
30
-		$this->expectException(\Yoshi2889\Container\NotFoundException::class);
31
-		$container->get(\Yoshi2889\Container\Tests\SampleInvalidComponent::class);
32
-	}
33
-
34
-	public function testGetInvalidType()
35
-	{
36
-		$container = new ComponentContainer();
37
-		$this->expectException(\Yoshi2889\Container\ContainerException::class);
38
-		$container->get(10);
39
-	}
40
-
41
-	public function testGetNotFound()
42
-	{
43
-		$emptyContainer = new ComponentContainer();
44
-		$this->expectException(\Yoshi2889\Container\NotFoundException::class);
45
-		\Yoshi2889\Container\Tests\SampleComponent::fromContainer($emptyContainer);
46
-	}
47
-
48
-	public function testContainerHas()
49
-	{
50
-		$container = new ComponentContainer();
51
-
52
-		self::assertFalse($container->has(\Yoshi2889\Container\Tests\SampleComponent::class));
53
-
54
-		$sampleComponent = new \Yoshi2889\Container\Tests\SampleComponent();
55
-		$container->add($sampleComponent);
56
-
57
-		self::assertTrue($container->has(\Yoshi2889\Container\Tests\SampleComponent::class));
58
-
59
-		$this->expectException(\Yoshi2889\Container\ContainerException::class);
60
-		$container->has(10);
61
-	}
14
+    public function testContainerGet()
15
+    {
16
+        $container = new ComponentContainer();
17
+
18
+        $sampleComponent = new \Yoshi2889\Container\Tests\SampleComponent();
19
+        $container->add($sampleComponent);
20
+
21
+        $sampleComponentFromContainer = \Yoshi2889\Container\Tests\SampleComponent::fromContainer($container);
22
+
23
+        self::assertInstanceOf(\Yoshi2889\Container\Tests\SampleComponent::class, $sampleComponentFromContainer);
24
+        self::assertEquals($sampleComponent, $sampleComponentFromContainer);
25
+    }
26
+
27
+    public function testGetInvalidComponent()
28
+    {
29
+        $container = new ComponentContainer();
30
+        $this->expectException(\Yoshi2889\Container\NotFoundException::class);
31
+        $container->get(\Yoshi2889\Container\Tests\SampleInvalidComponent::class);
32
+    }
33
+
34
+    public function testGetInvalidType()
35
+    {
36
+        $container = new ComponentContainer();
37
+        $this->expectException(\Yoshi2889\Container\ContainerException::class);
38
+        $container->get(10);
39
+    }
40
+
41
+    public function testGetNotFound()
42
+    {
43
+        $emptyContainer = new ComponentContainer();
44
+        $this->expectException(\Yoshi2889\Container\NotFoundException::class);
45
+        \Yoshi2889\Container\Tests\SampleComponent::fromContainer($emptyContainer);
46
+    }
47
+
48
+    public function testContainerHas()
49
+    {
50
+        $container = new ComponentContainer();
51
+
52
+        self::assertFalse($container->has(\Yoshi2889\Container\Tests\SampleComponent::class));
53
+
54
+        $sampleComponent = new \Yoshi2889\Container\Tests\SampleComponent();
55
+        $container->add($sampleComponent);
56
+
57
+        self::assertTrue($container->has(\Yoshi2889\Container\Tests\SampleComponent::class));
58
+
59
+        $this->expectException(\Yoshi2889\Container\ContainerException::class);
60
+        $container->has(10);
61
+    }
62 62
 }
Please login to merge, or discard this patch.