Format code

This commit is contained in:
Marco Petersen
2018-09-12 23:25:22 +03:00
parent 60119c5b1b
commit f1b9ffd160
40 changed files with 257 additions and 301 deletions

View File

@@ -1,4 +1,5 @@
<?php
namespace App\Entity;
use App\Entity\Attribut\IdAttribut;
@@ -6,22 +7,20 @@ use App\Entity\Attribut\NodeAttribut;
use Doctrine\ORM\Mapping as ORM;
/**
*
* @author kevinfrantz
*
* @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/inheritance-mapping.html
* @ORM\Entity
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({"user" = "User"})
* @ORM\DiscriminatorMap({"user" = "User"})
*/
abstract class AbstractSource implements SourceInterface
{
{
use IdAttribut,NodeAttribut;
/**
*
* @var ConfigurationInterface
*/
protected $configuration;
}
}

View File

@@ -1,36 +1,35 @@
<?php
namespace App\Entity\Attribut;
use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\NodeInterface;
/**
*
* @author kevinfrantz
*
*/
trait ChildsAttribut {
trait ChildsAttribut
{
/**
* Many Nodes have many childs
* Many Nodes have many childs.
*
* @ORM\ManyToMany(targetEntity="Node")
* @ORM\JoinTable(name="nodes_childs",
* joinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")}
* )
*
* @var ArrayCollection|NodeInterface[]
*/
protected $childs;
public function getChilds(): ArrayCollection
{
return $this->getChilds();
}
public function setChilds(ArrayCollection $childs): void
{
$this->childs = $childs;
}
}

View File

@@ -1,15 +1,15 @@
<?php
namespace App\Entity\Attribut;
use Doctrine\Common\Collections\ArrayCollection;
/**
*
* @author kevinfrantz
*
*/
interface ChildsAttributeInterface
{
public function setChilds(ArrayCollection $childs):void;
public function getChilds():ArrayCollection;
}
public function setChilds(ArrayCollection $childs): void;
public function getChilds(): ArrayCollection;
}

View File

@@ -1,27 +1,26 @@
<?php
namespace App\Entity\Attribut;
/**
*
* @author kevinfrantz
*
*/
trait IdAttribut {
trait IdAttribut
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")(strategy="AUTO")
*/
protected $id;
public function setId(int $id): void
{
$this->id = $id;
}
public function getId(): int
{
return $this->id;
}
}

View File

@@ -1,15 +1,13 @@
<?php
namespace App\Entity\Attribut;
/**
*
* @author kevinfrantz
*
*/
interface IdAttributInterface
{
public function setId(int $id): void;
public function getId(): int;
}

View File

@@ -1,30 +1,28 @@
<?php
namespace App\Entity\Attribut;
use App\Entity\NodeInterface;
/**
*
* @author kevinfrantz
*
*/
trait NodeAttribut{
trait NodeAttribut
{
/**
* @var NodeInterface
* @ORM\OneToOne(targetEntity="Node")
* @ORM\JoinColumn(name="node_id", referencedColumnName="id")
*/
protected $node;
public function setNode(NodeInterface $node): void
{
$this->node = $node;
}
public function getNode(): NodeInterface
{
return $this->node;
}
}

View File

@@ -1,17 +1,15 @@
<?php
namespace App\Entity\Attribut;
use App\Entity\NodeInterface;
/**
*
* @author kevinfrantz
*
*/
interface NodeAttributInterface
{
public function setNode(NodeInterface $node):void;
public function getNode():NodeInterface;
}
public function setNode(NodeInterface $node): void;
public function getNode(): NodeInterface;
}

View File

@@ -1,24 +1,24 @@
<?php
namespace App\Entity\Attribut;
use Doctrine\Common\Collections\ArrayCollection;
use App\Entity\NodeInterface;
/**
*
* @author kevinfrantz
*
*/
trait ParentAttribut {
trait ParentAttribut
{
/**
* Many Nodes have many parents
* Many Nodes have many parents.
*
* @ORM\ManyToMany(targetEntity="Node")
* @ORM\JoinTable(name="nodes_parents",
* joinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="node_id", referencedColumnName="id")}
* )
*
* @var ArrayCollection|NodeInterface[]
*/
protected $parents;
@@ -33,4 +33,3 @@ trait ParentAttribut {
$this->parents = $parents;
}
}

View File

@@ -1,17 +1,15 @@
<?php
namespace App\Entity\Attribut;
use Doctrine\Common\Collections\ArrayCollection;
/**
*
* @author kevinfrantz
*
*/
interface ParentsAttributInterface
{
public function setParents(ArrayCollection $parents):void;
public function getParents():ArrayCollection;
}
public function setParents(ArrayCollection $parents): void;
public function getParents(): ArrayCollection;
}

View File

@@ -1,24 +1,24 @@
<?php
namespace App\Entity\Attribut;
/**
*
* @author kevinfrantz
*
*/
trait PasswordAttribut {
trait PasswordAttribut
{
/**
* @ORM\Column(type="string", length=64)
*/
protected $password;
public function getPassword():?string
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password):void{
public function setPassword(string $password): void
{
$this->password = $password;
}
}

View File

@@ -1,18 +1,18 @@
<?php
namespace App\Entity\Attribut;
use Symfony\Component\Validator\Constraints as Assert;
/**
*
* @author kevinfrantz
*
*/
trait PlainPasswordAttribute {
trait PlainPasswordAttribute
{
/**
*
* @Assert\NotBlank()
* @Assert\Length(max=4096)
*
* @var string
*/
private $plainPassword;
@@ -27,4 +27,3 @@ trait PlainPasswordAttribute {
$this->plainPassword = $password;
}
}

View File

@@ -1,27 +1,29 @@
<?php
namespace App\Entity\Attribut;
use App\Entity\SourceInterface;
/**
*
* @author kevinfrantz
*
*/
trait SourceAttribut {
trait SourceAttribut
{
/**
* @ORM\OneToOne(targetEntity="AbstractSource")
* @ORM\JoinColumn(name="source_id", referencedColumnName="id")
*
* @var SourceInterface
*/
protected $source;
public function getSource():SourceInterface{
public function getSource(): SourceInterface
{
return $this->source;
}
public function setSource(SourceInterface $source):void{
public function setSource(SourceInterface $source): void
{
$this->source = $source;
}
}

View File

@@ -1,17 +1,15 @@
<?php
namespace App\Entity\Attribut;
use App\Entity\SourceInterface;
/**
*
* @author kevinfrantz
*
*/
interface SourceAttributInterface
{
public function getSource():SourceInterface;
public function setSource(SourceInterface $source):void;
}
public function getSource(): SourceInterface;
public function setSource(SourceInterface $source): void;
}

View File

@@ -1,25 +1,26 @@
<?php
namespace App\Entity\Attribut;
/**
* This trait doesn't need an own interface because it's covered by symfony
* This trait doesn't need an own interface because it's covered by symfony.
*
* @author kevinfrantz
*
*/
trait UsernameAttribut{
trait UsernameAttribut
{
/**
* @ORM\Column(type="string", length=25, unique=true)
*/
protected $username;
public function getUsername():?string
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(string $username):void{
public function setUsername(string $username): void
{
$this->username = \trim($username);
}
}

View File

@@ -1,48 +1,48 @@
<?php
namespace App\Entity;
/**
*
* @author kevinfrantz
*
*/
class Configuration implements ConfigurationInterface
{
/**
*
* @var PropertyInterface
*/
protected $read;
/**
*
* @var PropertyInterface
*/
protected $write;
/**
*
* @var PropertyInterface
*/
protected $administrate;
public function setAdministrate(Property $administrate): void
{}
{
}
public function getAdministrate(): Property
{}
{
}
public function setWrite(Property $write): void
{}
{
}
public function getWrite(): Property
{}
{
}
public function setRead(Property $read): void
{}
{
}
public function getRead(): Property
{}
{
}
}

View File

@@ -1,24 +1,23 @@
<?php
namespace App\Entity;
/**
* This class is not a source!
*
* @author kevinfrantz
*
*/
interface ConfigurationInterface
{
public function setRead(Property $read):void;
public function getRead():Property;
public function setWrite(Property $write):void;
public function getWrite():Property;
public function setAdministrate(Property $administrate):void;
public function getAdministrate():Property;
}
public function setRead(Property $read): void;
public function getRead(): Property;
public function setWrite(Property $write): void;
public function getWrite(): Property;
public function setAdministrate(Property $administrate): void;
public function getAdministrate(): Property;
}

View File

@@ -1,4 +1,5 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
@@ -8,7 +9,6 @@ use App\Entity\Attribut\ParentAttribut;
use App\Entity\Attribut\ChildsAttribut;
/**
*
* @author kevinfrantz
* @ORM\Table(name="node")
* @ORM\Entity(repositoryClass="App\Repository\NodeRepository")
@@ -16,8 +16,7 @@ use App\Entity\Attribut\ChildsAttribut;
class Node implements NodeInterface
{
use IdAttribut,
SourceAttribut,
ParentAttribut,
SourceAttribut,
ParentAttribut,
ChildsAttribut;
}

View File

@@ -1,4 +1,5 @@
<?php
namespace App\Entity;
use App\Entity\Attribut\SourceAttributInterface;
@@ -7,10 +8,8 @@ use App\Entity\Attribut\ParentsAttributInterface;
use App\Entity\Attribut\ChildsAttributeInterface;
/**
*
* @author kevinfrantz
*
*/
interface NodeInterface extends SourceAttributInterface, IdAttributInterface,ParentsAttributInterface,ChildsAttributeInterface
{}
interface NodeInterface extends SourceAttributInterface, IdAttributInterface, ParentsAttributInterface, ChildsAttributeInterface
{
}

View File

@@ -1,32 +1,29 @@
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
/**
*
* @author kevinfrantz
*
*/
class Property implements PropertyInterface
{
/**
*
* @var ArrayCollection|NodeInterface[]
*/
protected $whitelist;
/**
*
* @var ArrayCollection|NodeInterface[]
*/
protected $blacklist;
public function getLegitimated(): ArrayCollection
{}
{
}
public function isLegitimated(SourceInterface $source): bool
{}
{
}
}

View File

@@ -1,17 +1,15 @@
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
/**
*
* @author kevinfrantz
*
*/
interface PropertyInterface
{
public function isLegitimated(SourceInterface $source):bool;
public function getLegitimated():ArrayCollection;
}
public function isLegitimated(SourceInterface $source): bool;
public function getLegitimated(): ArrayCollection;
}

View File

@@ -1,15 +1,13 @@
<?php
namespace App\Entity;
use App\Entity\Attribut\NodeAttributInterface;
use App\Entity\Attribut\IdAttributInterface;
/**
*
* @author kevinfrantz
*
*/
interface SourceInterface extends IdAttributInterface, NodeAttributInterface
{
}

View File

@@ -1,4 +1,5 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
@@ -7,7 +8,6 @@ use App\Entity\Attribut\PasswordAttribut;
use App\Entity\Attribut\PlainPasswordAttribute;
/**
*
* @author kevinfrantz
* @ORM\Table(name="source_user")
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
@@ -15,7 +15,7 @@ use App\Entity\Attribut\PlainPasswordAttribute;
class User extends AbstractSource implements UserInterface
{
use UsernameAttribut,PasswordAttribut,PlainPasswordAttribute;
/**
* @ORM\Column(name="is_active", type="boolean")
*/
@@ -33,7 +33,7 @@ class User extends AbstractSource implements UserInterface
public function getRoles()
{
return array('ROLE_USER');
return ['ROLE_USER'];
}
public function eraseCredentials()
@@ -43,20 +43,19 @@ class User extends AbstractSource implements UserInterface
/** @see \Serializable::serialize() */
public function serialize()
{
return serialize(array(
return serialize([
$this->id,
$this->username,
$this->password,
));
]);
}
/** @see \Serializable::unserialize() */
public function unserialize($serialized)
{
list (
list(
$this->id,
$this->username,
$this->password,
) = unserialize($serialized, array('allowed_classes' => false));
$this->password) = unserialize($serialized, ['allowed_classes' => false]);
}
}

View File

@@ -1,14 +1,12 @@
<?php
namespace App\Entity;
use Symfony\Component\Security\Core\User\UserInterface as SymfonyUserInterface;
/**
*
* @author kevinfrantz
*
*/
interface UserInterface extends SymfonyUserInterface, \Serializable
{
}