From 907650565631ccb57fc45fdc44595606bcf55256 Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Sun, 18 Nov 2018 11:41:24 +0100 Subject: [PATCH] Formated code --- .../SourceManagement/TreeSourceService.php | 11 +++---- .../Unit/Domain/TreeSourceServiceTest.php | 33 ++++++++++--------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/application/src/Domain/SourceManagement/TreeSourceService.php b/application/src/Domain/SourceManagement/TreeSourceService.php index 79dd53d..60d4ae3 100644 --- a/application/src/Domain/SourceManagement/TreeSourceService.php +++ b/application/src/Domain/SourceManagement/TreeSourceService.php @@ -1,4 +1,5 @@ getBranches() as $branchBranch) { if (!$allBranches->contains($branchBranch)) { $allBranches->add($branchBranch); - if($branchBranch instanceof TreeCollectionSourceInterface){ + if ($branchBranch instanceof TreeCollectionSourceInterface) { $this->itterateOverBranch($branchBranch, $allBranches); } } @@ -106,11 +104,12 @@ final class TreeSourceService extends AbstractSourceService implements TreeSourc $leaves = new ArrayCollection($this->getLeaves()->toArray()); foreach ($this->getAllBranches() as $branch) { foreach ((new self($branch))->getLeaves() as $leave) { - if (! $leaves->contains($leave)) { + if (!$leaves->contains($leave)) { $leaves->add($leave); } } } + return $leaves; } } diff --git a/application/tests/Unit/Domain/TreeSourceServiceTest.php b/application/tests/Unit/Domain/TreeSourceServiceTest.php index 647a4eb..cb4fd81 100644 --- a/application/tests/Unit/Domain/TreeSourceServiceTest.php +++ b/application/tests/Unit/Domain/TreeSourceServiceTest.php @@ -1,8 +1,8 @@ createMock(SourceInterface::class); $leave4 = $this->createMock(SourceInterface::class); $leave5 = $this->createMock(SourceInterface::class); - $tree2->setCollection(new ArrayCollection([$leave3,$leave4,$tree5,$leave5])); - $collection = new ArrayCollection([$tree2,$tree3,$leave1,$leave2,$tree4,$tree1]); + $tree2->setCollection(new ArrayCollection([$leave3, $leave4, $tree5, $leave5])); + $collection = new ArrayCollection([$tree2, $tree3, $leave1, $leave2, $tree4, $tree1]); $tree1->setCollection($collection); $this->treeService = new TreeSourceService($tree1); } - - public function testGetLeaves():void{ + + public function testGetLeaves(): void + { $this->assertEquals(2, $this->treeService->getLeaves()->count()); } - - public function testGetBranches():void{ + + public function testGetBranches(): void + { $this->assertEquals(4, $this->treeService->getBranches()->count()); } - - public function testGetAllBranches():void{ + + public function testGetAllBranches(): void + { $this->assertEquals(5, $this->treeService->getAllBranches()->count()); } - - public function testGetAllLeaves():void{ + + public function testGetAllLeaves(): void + { $this->assertEquals(5, $this->treeService->getAllLeaves()->count()); } } -