From 4b86acb372e23bad05e716b0a26cd3921aeb761a Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Sat, 19 Jan 2019 22:52:49 +0100 Subject: [PATCH] Optimized documentation and class naming --- .../src/Domain/AbstractDomainService.php | 12 ---- .../EntityMetaInformationInterface.php | 2 +- ...erService.php => LawPermissionChecker.php} | 4 +- ....php => LawPermissionCheckerInterface.php} | 4 +- .../Domain/MemberManagement/MemberManager.php | 7 ++ .../PathManagement/NamespacePathMap.php | 2 +- application/symfony/src/Domain/README.md | 69 +++++++++++++++++++ .../RightManagement/RightCheckerInterface.php | 2 + .../RightLayerCombinationServiceInterface.php | 2 + .../SecureManagement/SecureSourceChecker.php | 4 +- .../AbstractSourceService.php | 9 --- .../SourceMemberInformationInterface.php | 5 ++ .../SourceManagement/SourceMemberManager.php | 26 +++++++ .../SourceMemberManagerInterface.php | 5 ++ .../SourceMembershipInformation.php | 6 ++ .../SourceMembershipInformationInterface.php | 5 ++ .../SourceRightManagerInterface.php | 5 ++ ...eService.php => TreeSourceInformation.php} | 31 ++++++++- ...php => TreeSourceInformationInterface.php} | 7 +- .../TemplatePathInformationInterface.php | 2 + .../UserSourceDirectorInterface.php | 5 ++ .../UserSourceDirectorServiceInterface.php | 4 ++ .../LawPermissionCheckerTest.php | 8 +-- .../TreeSourceServiceTest.php | 10 +-- 24 files changed, 195 insertions(+), 41 deletions(-) delete mode 100644 application/symfony/src/Domain/AbstractDomainService.php rename application/symfony/src/Domain/LawManagement/{LawPermissionCheckerService.php => LawPermissionChecker.php} (96%) rename application/symfony/src/Domain/LawManagement/{LawPermissionCheckerServiceInterface.php => LawPermissionCheckerInterface.php} (73%) delete mode 100644 application/symfony/src/Domain/SourceManagement/AbstractSourceService.php rename application/symfony/src/Domain/SourceManagement/{TreeSourceService.php => TreeSourceInformation.php} (78%) rename application/symfony/src/Domain/SourceManagement/{TreeSourceServiceInterface.php => TreeSourceInformationInterface.php} (85%) diff --git a/application/symfony/src/Domain/AbstractDomainService.php b/application/symfony/src/Domain/AbstractDomainService.php deleted file mode 100644 index ff5dee7..0000000 --- a/application/symfony/src/Domain/AbstractDomainService.php +++ /dev/null @@ -1,12 +0,0 @@ -source->getLaw()); + $law = new LawPermissionChecker($this->source->getLaw()); return $law->hasPermission($requestedRight) && $this->itterateOverSourceAttributs($requestedRight); } diff --git a/application/symfony/src/Domain/SourceManagement/AbstractSourceService.php b/application/symfony/src/Domain/SourceManagement/AbstractSourceService.php deleted file mode 100644 index 16cc73b..0000000 --- a/application/symfony/src/Domain/SourceManagement/AbstractSourceService.php +++ /dev/null @@ -1,9 +0,0 @@ -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()); diff --git a/application/symfony/src/Domain/SourceManagement/SourceMemberManagerInterface.php b/application/symfony/src/Domain/SourceManagement/SourceMemberManagerInterface.php index 1aeaf54..90a3ba3 100644 --- a/application/symfony/src/Domain/SourceManagement/SourceMemberManagerInterface.php +++ b/application/symfony/src/Domain/SourceManagement/SourceMemberManagerInterface.php @@ -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 { /** diff --git a/application/symfony/src/Domain/SourceManagement/SourceMembershipInformation.php b/application/symfony/src/Domain/SourceManagement/SourceMembershipInformation.php index dfcae48..0ec99ed 100644 --- a/application/symfony/src/Domain/SourceManagement/SourceMembershipInformation.php +++ b/application/symfony/src/Domain/SourceManagement/SourceMembershipInformation.php @@ -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; diff --git a/application/symfony/src/Domain/SourceManagement/SourceMembershipInformationInterface.php b/application/symfony/src/Domain/SourceManagement/SourceMembershipInformationInterface.php index f1c738c..3fd7c69 100644 --- a/application/symfony/src/Domain/SourceManagement/SourceMembershipInformationInterface.php +++ b/application/symfony/src/Domain/SourceManagement/SourceMembershipInformationInterface.php @@ -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 { /** diff --git a/application/symfony/src/Domain/SourceManagement/SourceRightManagerInterface.php b/application/symfony/src/Domain/SourceManagement/SourceRightManagerInterface.php index f17557f..4a6b232 100644 --- a/application/symfony/src/Domain/SourceManagement/SourceRightManagerInterface.php +++ b/application/symfony/src/Domain/SourceManagement/SourceRightManagerInterface.php @@ -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 { /** diff --git a/application/symfony/src/Domain/SourceManagement/TreeSourceService.php b/application/symfony/src/Domain/SourceManagement/TreeSourceInformation.php similarity index 78% rename from application/symfony/src/Domain/SourceManagement/TreeSourceService.php rename to application/symfony/src/Domain/SourceManagement/TreeSourceInformation.php index 3283cfa..21e1791 100644 --- a/application/symfony/src/Domain/SourceManagement/TreeSourceService.php +++ b/application/symfony/src/Domain/SourceManagement/TreeSourceInformation.php @@ -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()); diff --git a/application/symfony/src/Domain/SourceManagement/TreeSourceServiceInterface.php b/application/symfony/src/Domain/SourceManagement/TreeSourceInformationInterface.php similarity index 85% rename from application/symfony/src/Domain/SourceManagement/TreeSourceServiceInterface.php rename to application/symfony/src/Domain/SourceManagement/TreeSourceInformationInterface.php index 9cadc83..0933c3e 100644 --- a/application/symfony/src/Domain/SourceManagement/TreeSourceServiceInterface.php +++ b/application/symfony/src/Domain/SourceManagement/TreeSourceInformationInterface.php @@ -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. diff --git a/application/symfony/src/Domain/TemplateManagement/TemplatePathInformationInterface.php b/application/symfony/src/Domain/TemplateManagement/TemplatePathInformationInterface.php index 45c3b9f..5f21f9c 100644 --- a/application/symfony/src/Domain/TemplateManagement/TemplatePathInformationInterface.php +++ b/application/symfony/src/Domain/TemplateManagement/TemplatePathInformationInterface.php @@ -22,6 +22,8 @@ interface TemplatePathInformationInterface extends ReloadTypeInterface public function getAtomTemplatePath(): string; /** + * @todo Check if this is really needed. Otherwise remove it! + * * @see RESTResponseType::$choices * * @return string Type of the template diff --git a/application/symfony/src/Domain/UserManagement/UserSourceDirectorInterface.php b/application/symfony/src/Domain/UserManagement/UserSourceDirectorInterface.php index fc0c5d9..5ba1662 100644 --- a/application/symfony/src/Domain/UserManagement/UserSourceDirectorInterface.php +++ b/application/symfony/src/Domain/UserManagement/UserSourceDirectorInterface.php @@ -4,6 +4,11 @@ namespace App\Domain\UserManagement; use App\Entity\UserInterface; +/** + * Offers based on an user variable a user with a source. + * + * @author kevinfrantz + */ interface UserSourceDirectorInterface { /** diff --git a/application/symfony/src/Domain/UserManagement/UserSourceDirectorServiceInterface.php b/application/symfony/src/Domain/UserManagement/UserSourceDirectorServiceInterface.php index dc9b20e..ca33c82 100644 --- a/application/symfony/src/Domain/UserManagement/UserSourceDirectorServiceInterface.php +++ b/application/symfony/src/Domain/UserManagement/UserSourceDirectorServiceInterface.php @@ -3,6 +3,10 @@ namespace App\Domain\UserManagement; /** + * Offers UserSourceDirector to be used as a Service. + * + * @see UserSourceDirector + * * @author kevinfrantz */ interface UserSourceDirectorServiceInterface extends UserSourceDirectorInterface diff --git a/application/symfony/tests/Unit/Domain/LawManagement/LawPermissionCheckerTest.php b/application/symfony/tests/Unit/Domain/LawManagement/LawPermissionCheckerTest.php index f87cf1f..576fdc4 100644 --- a/application/symfony/tests/Unit/Domain/LawManagement/LawPermissionCheckerTest.php +++ b/application/symfony/tests/Unit/Domain/LawManagement/LawPermissionCheckerTest.php @@ -3,8 +3,8 @@ namespace Unit\Domain\LawManagement; use PHPUnit\Framework\TestCase; -use App\Domain\LawManagement\LawPermissionCheckerService; -use App\Domain\LawManagement\LawPermissionCheckerServiceInterface; +use App\Domain\LawManagement\LawPermissionChecker; +use App\Domain\LawManagement\LawPermissionCheckerInterface; use App\Entity\Source\SourceInterface; use App\Entity\Meta\Right; use App\DBAL\Types\Meta\Right\LayerType; @@ -22,7 +22,7 @@ use App\Entity\Source\PureSource; class LawPermissionCheckerTest extends TestCase { /** - * @var LawPermissionCheckerServiceInterface The service which checks the law + * @var LawPermissionCheckerInterface The service which checks the law */ private $lawPermissionChecker; @@ -62,7 +62,7 @@ class LawPermissionCheckerTest extends TestCase private function setLawPermissionChecker(): void { - $this->lawPermissionChecker = new LawPermissionCheckerService($this->law); + $this->lawPermissionChecker = new LawPermissionChecker($this->law); } private function setLawDummy(): void diff --git a/application/symfony/tests/Unit/Domain/SourceManagement/TreeSourceServiceTest.php b/application/symfony/tests/Unit/Domain/SourceManagement/TreeSourceServiceTest.php index 8b726d7..512d224 100644 --- a/application/symfony/tests/Unit/Domain/SourceManagement/TreeSourceServiceTest.php +++ b/application/symfony/tests/Unit/Domain/SourceManagement/TreeSourceServiceTest.php @@ -6,13 +6,13 @@ use PHPUnit\Framework\TestCase; use App\Entity\Source\Complex\Collection\TreeCollectionSource; use App\Entity\Source\SourceInterface; use Doctrine\Common\Collections\ArrayCollection; -use App\Domain\SourceManagement\TreeSourceServiceInterface; -use App\Domain\SourceManagement\TreeSourceService; +use App\Domain\SourceManagement\TreeSourceInformationInterface; +use App\Domain\SourceManagement\TreeSourceInformation; -class TreeSourceServiceTest extends TestCase +class TreeSourceInformationTest extends TestCase { /** - * @var TreeSourceServiceInterface + * @var TreeSourceInformationInterface */ protected $treeService; @@ -31,7 +31,7 @@ class TreeSourceServiceTest extends TestCase $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); + $this->treeService = new TreeSourceInformation($tree1); } public function testGetLeaves(): void