Optimized documentation and class naming

This commit is contained in:
Kevin Frantz
2019-01-19 22:52:49 +01:00
parent 71c7a7f080
commit 4b86acb372
24 changed files with 195 additions and 41 deletions

View File

@@ -1,9 +0,0 @@
<?php
namespace App\Domain\SourceManagement;
use App\Domain\AbstractDomainService;
abstract class AbstractSourceService extends AbstractDomainService
{
}

View File

@@ -5,6 +5,11 @@ namespace App\Domain\SourceManagement;
use Doctrine\Common\Collections\Collection;
use App\Entity\Source\SourceInterface;
/**
* Offers to get all source members over all dimensions.
*
* @author kevinfrantz
*/
interface SourceMemberInformationInterface
{
/**

View File

@@ -6,6 +6,9 @@ use App\Entity\Source\SourceInterface;
use App\Domain\MemberManagement\MemberManagerInterface;
use App\Domain\MemberManagement\MemberManager;
/**
* @author kevinfrantz
*/
final class SourceMemberManager implements SourceMemberManagerInterface
{
/**
@@ -18,27 +21,50 @@ final class SourceMemberManager implements SourceMemberManagerInterface
*/
private $memberManager;
/**
* @param SourceInterface $source
*/
public function __construct(SourceInterface $source)
{
$this->source = $source;
$this->memberManager = new MemberManager($this->source->getMemberRelation());
}
/**
* {@inheritdoc}
*
* @see \App\Domain\SourceManagement\SourceMemberManagerInterface::addMember()
*/
public function addMember(SourceInterface $member): void
{
$this->memberManager->addMember($member->getMemberRelation());
}
/**
* {@inheritdoc}
*
* @see \App\Domain\SourceManagement\SourceMemberManagerInterface::removeMember()
*/
public function removeMember(SourceInterface $member): void
{
$this->memberManager->removeMember($member->getMemberRelation());
}
/**
* {@inheritdoc}
*
* @see \App\Domain\SourceManagement\SourceMemberManagerInterface::addMembership()
*/
public function addMembership(SourceInterface $membership): void
{
$this->memberManager->addMembership($membership->getMemberRelation());
}
/**
* {@inheritdoc}
*
* @see \App\Domain\SourceManagement\SourceMemberManagerInterface::removeMembership()
*/
public function removeMembership(SourceInterface $membership): void
{
$this->memberManager->removeMembership($membership->getMemberRelation());

View File

@@ -4,6 +4,11 @@ namespace App\Domain\SourceManagement;
use App\Entity\Source\SourceInterface;
/**
* Offers to add and remove source members and memberships.
*
* @author kevinfrantz
*/
interface SourceMemberManagerInterface
{
/**

View File

@@ -7,6 +7,9 @@ use App\Entity\Source\SourceInterface;
use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\Meta\Relation\Member\MemberRelationInterface;
/**
* @author kevinfrantz
*/
final class SourceMembershipInformation implements SourceMembershipInformationInterface
{
/**
@@ -19,6 +22,9 @@ final class SourceMembershipInformation implements SourceMembershipInformationIn
*/
private $memberships;
/**
* @param SourceInterface $source
*/
public function __construct(SourceInterface $source)
{
$this->source = $source;

View File

@@ -5,6 +5,11 @@ namespace App\Domain\SourceManagement;
use Doctrine\Common\Collections\Collection;
use App\Entity\Source\SourceInterface;
/**
* Offers to get all memberships of a source.
*
* @author kevinfrantz
*/
interface SourceMembershipInformationInterface
{
/**

View File

@@ -7,6 +7,11 @@ use App\Exception\AllreadySetException;
use App\Exception\AllreadyDefinedException;
use App\Exception\NotSetException;
/**
* Allows to add and remove rights of a source.
*
* @author kevinfrantz
*/
interface SourceRightManagerInterface
{
/**

View File

@@ -15,7 +15,7 @@ use App\Entity\Source\SourceInterface;
*
* @todo Maybe lazy loading would be helpfull for performance
*/
final class TreeSourceService extends AbstractSourceService implements TreeSourceServiceInterface
final class TreeSourceInformation implements TreeSourceInformationInterface
{
/**
* @var TreeCollectionSourceInterface
@@ -36,6 +36,9 @@ final class TreeSourceService extends AbstractSourceService implements TreeSourc
*/
private $leaves;
/**
* @param TreeCollectionSource $source
*/
public function __construct(TreeCollectionSource $source)
{
$this->source = $source;
@@ -44,6 +47,11 @@ final class TreeSourceService extends AbstractSourceService implements TreeSourc
$this->basicSort();
}
/**
* @param SourceInterface $member
*
* @return bool
*/
private function sortMember(SourceInterface $member): bool
{
if ($member instanceof TreeCollectionSource) {
@@ -60,6 +68,11 @@ final class TreeSourceService extends AbstractSourceService implements TreeSourc
}
}
/**
* {@inheritdoc}
*
* @see \App\Domain\SourceManagement\TreeSourceInformationInterface::getBranches()
*/
public function getBranches(): Collection
{
return $this->branches;
@@ -70,7 +83,7 @@ final class TreeSourceService extends AbstractSourceService implements TreeSourc
* @todo Remove the getAllBranches use inside the function.
* {@inheritdoc}
*
* @see \App\Domain\SourceManagement\TreeSourceServiceInterface::getAllBranches()
* @see \App\Domain\SourceManagement\TreeSourceInformationInterface::getAllBranches()
*/
public function getAllBranches(): Collection
{
@@ -82,6 +95,10 @@ final class TreeSourceService extends AbstractSourceService implements TreeSourc
return $allBranches;
}
/**
* @param TreeCollectionSourceInterface $branch
* @param ArrayCollection $allBranches
*/
private function itterateOverBranch(TreeCollectionSourceInterface $branch, ArrayCollection $allBranches): void
{
foreach ((new self($branch))->getBranches() as $branchBranch) {
@@ -94,11 +111,21 @@ final class TreeSourceService extends AbstractSourceService implements TreeSourc
}
}
/**
* {@inheritdoc}
*
* @see \App\Domain\SourceManagement\TreeSourceInformationInterface::getLeaves()
*/
public function getLeaves(): Collection
{
return $this->leaves;
}
/**
* {@inheritdoc}
*
* @see \App\Domain\SourceManagement\TreeSourceInformationInterface::getAllLeaves()
*/
public function getAllLeaves(): Collection
{
$leaves = new ArrayCollection($this->getLeaves()->toArray());

View File

@@ -4,7 +4,12 @@ namespace App\Domain\SourceManagement;
use Doctrine\Common\Collections\Collection;
interface TreeSourceServiceInterface
/**
* Allows to get branches and leaves of a tree.
*
* @author kevinfrantz
*/
interface TreeSourceInformationInterface
{
/**
* Delivers the branches of the actual tree back.