Formated code

This commit is contained in:
Kevin Frantz
2018-11-18 11:41:24 +01:00
parent 9137c55b17
commit 9076505656
2 changed files with 23 additions and 21 deletions

View File

@@ -1,4 +1,5 @@
<?php
namespace App\Domain\SourceManagement;
use App\Entity\Source\Collection\TreeCollectionSourceInterface;
@@ -11,14 +12,12 @@ use App\Entity\Source\SourceInterface;
* Allows to iterate over a tree.
*
* @author kevinfrantz
*
*
* @todo Maybe lazy loading would be helpfull for performance
*/
final class TreeSourceService extends AbstractSourceService implements TreeSourceServiceInterface
{
/**
*
* @var TreeCollectionSourceInterface
*/
private $source;
@@ -67,7 +66,6 @@ final class TreeSourceService extends AbstractSourceService implements TreeSourc
}
/**
*
* @todo Remove the optional parameter and put the logic in a private funtion.
* @todo Remove the getAllBranches use inside the function.
* {@inheritdoc}
@@ -89,7 +87,7 @@ final class TreeSourceService extends AbstractSourceService implements TreeSourc
foreach ((new self($branch))->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;
}
}