Completed
Pull Request — master (#2)
by Ondrej
01:50
created
src/VotingDecisionEnum.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
 
40 40
 
41 41
     /**
42
-     * @param $string
42
+     * @param string $string
43 43
      * @return self
44 44
      */
45 45
     private static function instance($string)
Please login to merge, or discard this patch.
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -4,58 +4,58 @@
 block discarded – undo
4 4
 
5 5
 final class VotingDecisionEnum
6 6
 {
7
-    /**
8
-     * @var string
9
-     */
10
-    private $value;
11
-
12
-    /**
13
-     * @var self[]
14
-     */
15
-    static private $registry = [];
16
-
17
-    private function __construct($value)
18
-    {
19
-        $this->value = $value;
20
-    }
21
-
22
-
23
-    /**
24
-     * @return self
25
-     */
26
-    public static function ALLOWED()
27
-    {
28
-        return static::instance('allowed');
29
-    }
30
-
31
-
32
-    /**
33
-     * @return self
34
-     */
35
-    public static function DENIED()
36
-    {
37
-        return static::instance('denied');
38
-    }
39
-
40
-
41
-    /**
42
-     * @param $string
43
-     * @return self
44
-     */
45
-    private static function instance($string)
46
-    {
47
-        if (!isset(static::$registry[$string])) {
48
-            static::$registry[$string] = new static($string);
49
-        }
50
-        return static::$registry[$string];
51
-    }
52
-
53
-
54
-    /**
55
-     * @return string
56
-     */
57
-    public function __toString()
58
-    {
59
-        return $this->value;
60
-    }
7
+	/**
8
+	 * @var string
9
+	 */
10
+	private $value;
11
+
12
+	/**
13
+	 * @var self[]
14
+	 */
15
+	static private $registry = [];
16
+
17
+	private function __construct($value)
18
+	{
19
+		$this->value = $value;
20
+	}
21
+
22
+
23
+	/**
24
+	 * @return self
25
+	 */
26
+	public static function ALLOWED()
27
+	{
28
+		return static::instance('allowed');
29
+	}
30
+
31
+
32
+	/**
33
+	 * @return self
34
+	 */
35
+	public static function DENIED()
36
+	{
37
+		return static::instance('denied');
38
+	}
39
+
40
+
41
+	/**
42
+	 * @param $string
43
+	 * @return self
44
+	 */
45
+	private static function instance($string)
46
+	{
47
+		if (!isset(static::$registry[$string])) {
48
+			static::$registry[$string] = new static($string);
49
+		}
50
+		return static::$registry[$string];
51
+	}
52
+
53
+
54
+	/**
55
+	 * @return string
56
+	 */
57
+	public function __toString()
58
+	{
59
+		return $this->value;
60
+	}
61 61
 }
62 62
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     /**
13 13
      * @var self[]
14 14
      */
15
-    static private $registry = [];
15
+    static private $registry = [ ];
16 16
 
17 17
     private function __construct($value)
18 18
     {
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
      */
54 54
     private static function instance($string)
55 55
     {
56
-        if (!isset(static::$registry[$string])) {
57
-            static::$registry[$string] = new static($string);
56
+        if (!isset(static::$registry[ $string ])) {
57
+            static::$registry[ $string ] = new static($string);
58 58
         }
59
-        return static::$registry[$string];
59
+        return static::$registry[ $string ];
60 60
     }
61 61
 
62 62
 
Please login to merge, or discard this patch.
src/StrategyEnum.php 3 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -4,67 +4,67 @@
 block discarded – undo
4 4
 
5 5
 class StrategyEnum
6 6
 {
7
-    /**
8
-     * @var string
9
-     */
10
-    private $value;
7
+	/**
8
+	 * @var string
9
+	 */
10
+	private $value;
11 11
 
12
-    /**
13
-     * @var self[]
14
-     */
15
-    static private $registry = [];
12
+	/**
13
+	 * @var self[]
14
+	 */
15
+	static private $registry = [];
16 16
 
17
-    private function __construct($value)
18
-    {
19
-        $this->value = $value;
20
-    }
17
+	private function __construct($value)
18
+	{
19
+		$this->value = $value;
20
+	}
21 21
 
22 22
 
23
-    /**
24
-     * @return self
25
-     */
26
-    public static function FIRST_VOTE_DECIDES()
27
-    {
28
-        return static::instance('first_vote_decides');
29
-    }
23
+	/**
24
+	 * @return self
25
+	 */
26
+	public static function FIRST_VOTE_DECIDES()
27
+	{
28
+		return static::instance('first_vote_decides');
29
+	}
30 30
 
31 31
 
32
-    /**
33
-     * @return self
34
-     */
35
-    public static function ALLOW_UNLESS_DENIED()
36
-    {
37
-        return static::instance('allow_unless_denied');
38
-    }
32
+	/**
33
+	 * @return self
34
+	 */
35
+	public static function ALLOW_UNLESS_DENIED()
36
+	{
37
+		return static::instance('allow_unless_denied');
38
+	}
39 39
 
40 40
 
41
-    /**
42
-     * @return self
43
-     */
44
-    public static function DENY_UNLESS_ALLOWED()
45
-    {
46
-        return static::instance('deny_unless_allowed');
47
-    }
41
+	/**
42
+	 * @return self
43
+	 */
44
+	public static function DENY_UNLESS_ALLOWED()
45
+	{
46
+		return static::instance('deny_unless_allowed');
47
+	}
48 48
 
49 49
 
50
-    /**
51
-     * @param $string
52
-     * @return self
53
-     */
54
-    private static function instance($string)
55
-    {
56
-        if (!isset(static::$registry[$string])) {
57
-            static::$registry[$string] = new static($string);
58
-        }
59
-        return static::$registry[$string];
60
-    }
50
+	/**
51
+	 * @param $string
52
+	 * @return self
53
+	 */
54
+	private static function instance($string)
55
+	{
56
+		if (!isset(static::$registry[$string])) {
57
+			static::$registry[$string] = new static($string);
58
+		}
59
+		return static::$registry[$string];
60
+	}
61 61
 
62 62
 
63
-    /**
64
-     * @return string
65
-     */
66
-    public function __toString()
67
-    {
68
-        return $this->value;
69
-    }
63
+	/**
64
+	 * @return string
65
+	 */
66
+	public function __toString()
67
+	{
68
+		return $this->value;
69
+	}
70 70
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     /**
13 13
      * @var self[]
14 14
      */
15
-    static private $registry = [];
15
+    static private $registry = [ ];
16 16
 
17 17
     private function __construct($value)
18 18
     {
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
      */
54 54
     private static function instance($string)
55 55
     {
56
-        if (!isset(static::$registry[$string])) {
57
-            static::$registry[$string] = new static($string);
56
+        if (!isset(static::$registry[ $string ])) {
57
+            static::$registry[ $string ] = new static($string);
58 58
         }
59
-        return static::$registry[$string];
59
+        return static::$registry[ $string ];
60 60
     }
61 61
 
62 62
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
 
40 40
 
41 41
     /**
42
-     * @param $string
42
+     * @param string $string
43 43
      * @return self
44 44
      */
45 45
     private static function instance($string)
Please login to merge, or discard this patch.
src/VotingResult.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -5,43 +5,43 @@
 block discarded – undo
5 5
 
6 6
 class VotingResult implements IVotingResult
7 7
 {
8
-    /**
9
-     * @var VotingDecisionEnum
10
-     */
11
-    private $decision;
12
-
13
-    /**
14
-     * @var ISingleVoterResult[]
15
-     */
16
-    private $partialResults;
17
-
18
-
19
-    /**
20
-     * VotingResult constructor.
21
-     * @param VotingDecisionEnum $decision
22
-     * @param ISingleVoterResult[] $partialResults
23
-     */
24
-    public function __construct(VotingDecisionEnum $decision, $partialResults)
8
+	/**
9
+	 * @var VotingDecisionEnum
10
+	 */
11
+	private $decision;
12
+
13
+	/**
14
+	 * @var ISingleVoterResult[]
15
+	 */
16
+	private $partialResults;
17
+
18
+
19
+	/**
20
+	 * VotingResult constructor.
21
+	 * @param VotingDecisionEnum $decision
22
+	 * @param ISingleVoterResult[] $partialResults
23
+	 */
24
+	public function __construct(VotingDecisionEnum $decision, $partialResults)
25 25
 	{
26
-        $this->decision = $decision;
27
-        $this->partialResults = $partialResults;
28
-    }
29
-
30
-
31
-    /**
32
-     * @return VotingDecisionEnum
33
-     */
34
-    public function getDecision()
35
-    {
36
-        return $this->decision;
37
-    }
38
-
39
-
40
-    /**
41
-     * @return ISingleVoterResult[]
42
-     */
43
-    public function getPartialResults()
44
-    {
45
-        return $this->partialResults;
46
-    }
26
+		$this->decision = $decision;
27
+		$this->partialResults = $partialResults;
28
+	}
29
+
30
+
31
+	/**
32
+	 * @return VotingDecisionEnum
33
+	 */
34
+	public function getDecision()
35
+	{
36
+		return $this->decision;
37
+	}
38
+
39
+
40
+	/**
41
+	 * @return ISingleVoterResult[]
42
+	 */
43
+	public function getPartialResults()
44
+	{
45
+		return $this->partialResults;
46
+	}
47 47
 }
Please login to merge, or discard this patch.
src/GenericVotingManager.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@
 block discarded – undo
25 25
 	 */
26 26
 	public function vote($action, $votingSubject, IVotingContext $votingContext)
27 27
 	{
28
-        if (!($votingSubject instanceof IVotingSubject)) {
29
-            $votingSubject = new VotingSubject($votingSubject);
30
-        }
28
+		if (!($votingSubject instanceof IVotingSubject)) {
29
+			$votingSubject = new VotingSubject($votingSubject);
30
+		}
31 31
 
32
-        return $this->innerVote($action, $votingSubject, $votingContext);
32
+		return $this->innerVote($action, $votingSubject, $votingContext);
33 33
 	}
34 34
 }
35 35
\ No newline at end of file
Please login to merge, or discard this patch.
src/Assembly/VotingAssembly.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	{
90 90
 		foreach ($this->voters as $voter) {
91 91
 			if (($lastResult = $voter->vote($votingSubject, $votingContext)) !== null) {
92
-                return new VotingResult($lastResult->getDecision(), [$lastResult]);
92
+                return new VotingResult($lastResult->getDecision(), [ $lastResult ]);
93 93
 			}
94 94
 		}
95 95
 		throw new InvalidVotingResultException('Voting assembly did not decide on any result!');
@@ -103,10 +103,10 @@  discard block
 block discarded – undo
103 103
 	 */
104 104
 	private function strategyAllowUnlessDenied($votingSubject, $votingContext)
105 105
 	{
106
-	    $results = [];
106
+	    $results = [ ];
107 107
 		foreach ($this->voters as $name => $voter) {
108 108
 			if (($lastResult = $voter->vote($votingSubject, $votingContext)) !== null) {
109
-                $results[] = $lastResult;
109
+                $results[ ] = $lastResult;
110 110
 			    if ($lastResult->getDecision() == VotingDecisionEnum::DENIED()) {
111 111
                     return new VotingResult(VotingDecisionEnum::DENIED(), $results);
112 112
                 }
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
 	 */
124 124
 	private function strategyDenyUnlessAllowed($votingSubject, $votingContext)
125 125
 	{
126
-        $results = [];
126
+        $results = [ ];
127 127
         foreach ($this->voters as $name => $voter) {
128 128
             if (($lastResult = $voter->vote($votingSubject, $votingContext)) !== null) {
129
-                $results[] = $lastResult;
129
+                $results[ ] = $lastResult;
130 130
                 if ($lastResult->getDecision() == VotingDecisionEnum::DENIED()) {
131 131
                     return new VotingResult(VotingDecisionEnum::ALLOWED(), $results);
132 132
                 }
Please login to merge, or discard this patch.
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	{
90 90
 		foreach ($this->voters as $voter) {
91 91
 			if (($lastResult = $voter->vote($votingSubject, $votingContext)) !== null) {
92
-                return new VotingResult($lastResult->getDecision(), [$lastResult]);
92
+				return new VotingResult($lastResult->getDecision(), [$lastResult]);
93 93
 			}
94 94
 		}
95 95
 		throw new InvalidVotingResultException('Voting assembly did not decide on any result!');
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
 	 */
104 104
 	private function strategyAllowUnlessDenied($votingSubject, $votingContext)
105 105
 	{
106
-	    $results = [];
106
+		$results = [];
107 107
 		foreach ($this->voters as $name => $voter) {
108 108
 			if (($lastResult = $voter->vote($votingSubject, $votingContext)) !== null) {
109
-                $results[] = $lastResult;
110
-			    if ($lastResult->getDecision() === VotingDecisionEnum::DENIED()) {
111
-                    return new VotingResult(VotingDecisionEnum::DENIED(), $results);
112
-                }
109
+				$results[] = $lastResult;
110
+				if ($lastResult->getDecision() === VotingDecisionEnum::DENIED()) {
111
+					return new VotingResult(VotingDecisionEnum::DENIED(), $results);
112
+				}
113 113
 			}
114 114
 		}
115 115
 		return new VotingResult(VotingDecisionEnum::ALLOWED(), $results);
@@ -123,16 +123,16 @@  discard block
 block discarded – undo
123 123
 	 */
124 124
 	private function strategyDenyUnlessAllowed($votingSubject, $votingContext)
125 125
 	{
126
-        $results = [];
127
-        foreach ($this->voters as $name => $voter) {
128
-            if (($lastResult = $voter->vote($votingSubject, $votingContext)) !== null) {
129
-                $results[] = $lastResult;
130
-                if ($lastResult->getDecision() === VotingDecisionEnum::ALLOWED()) {
131
-                    return new VotingResult(VotingDecisionEnum::ALLOWED(), $results);
132
-                }
133
-            }
134
-        }
135
-        return new VotingResult(VotingDecisionEnum::DENIED(), $results);
126
+		$results = [];
127
+		foreach ($this->voters as $name => $voter) {
128
+			if (($lastResult = $voter->vote($votingSubject, $votingContext)) !== null) {
129
+				$results[] = $lastResult;
130
+				if ($lastResult->getDecision() === VotingDecisionEnum::ALLOWED()) {
131
+					return new VotingResult(VotingDecisionEnum::ALLOWED(), $results);
132
+				}
133
+			}
134
+		}
135
+		return new VotingResult(VotingDecisionEnum::DENIED(), $results);
136 136
 	}
137 137
 
138 138
 
Please login to merge, or discard this patch.
src/IResult.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 
5 5
 interface IResult
6 6
 {
7
-    /**
8
-     * @return VotingDecisionEnum
9
-     */
10
-    public function getDecision();
7
+	/**
8
+	 * @return VotingDecisionEnum
9
+	 */
10
+	public function getDecision();
11 11
 }
12 12
\ No newline at end of file
Please login to merge, or discard this patch.
src/Voter/RoleVoter.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -12,28 +12,28 @@
 block discarded – undo
12 12
 	private $allowedRoles;
13 13
 
14 14
 	/**
15
-     * @var VotingDecisionEnum
16
-     */
17
-    private $resultDecision;
18
-
19
-    /**
20
-     * @var mixed|null
21
-     */
22
-    private $reason;
23
-
24
-
25
-    /**
26
-     * RoleVoter constructor.
27
-     * @param VotingDecisionEnum $resultDecision
28
-     * @param string|string[] $allowedRoles
29
-     * @param mixed $reason
30
-     */
15
+	 * @var VotingDecisionEnum
16
+	 */
17
+	private $resultDecision;
18
+
19
+	/**
20
+	 * @var mixed|null
21
+	 */
22
+	private $reason;
23
+
24
+
25
+	/**
26
+	 * RoleVoter constructor.
27
+	 * @param VotingDecisionEnum $resultDecision
28
+	 * @param string|string[] $allowedRoles
29
+	 * @param mixed $reason
30
+	 */
31 31
 	public function __construct(VotingDecisionEnum $resultDecision, $allowedRoles, $reason = null)
32 32
 	{
33 33
 		$this->allowedRoles = (array) $allowedRoles;
34
-        $this->resultDecision = $resultDecision;
35
-        $this->reason = $reason;
36
-    }
34
+		$this->resultDecision = $resultDecision;
35
+		$this->reason = $reason;
36
+	}
37 37
 
38 38
 
39 39
 	/**
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
      */
31 31
 	public function __construct(VotingDecisionEnum $resultDecision, $allowedRoles, $reason = null)
32 32
 	{
33
-		$this->allowedRoles = (array) $allowedRoles;
33
+		$this->allowedRoles = (array)$allowedRoles;
34 34
         $this->resultDecision = $resultDecision;
35 35
         $this->reason = $reason;
36 36
     }
Please login to merge, or discard this patch.
src/Voter/VotingSubject.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,12 +27,12 @@
 block discarded – undo
27 27
 	 */
28 28
 	public function getVotingSubjectName()
29 29
 	{
30
-	    if (is_string($this->subject)) {
31
-            return $this->subject;
32
-        }
33
-        if (is_object($this->subject)) {
34
-            return get_class($this->subject);
35
-        }
30
+		if (is_string($this->subject)) {
31
+			return $this->subject;
32
+		}
33
+		if (is_object($this->subject)) {
34
+			return get_class($this->subject);
35
+		}
36 36
 		return (string) $this->subject;
37 37
 	}
38 38
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,6 +33,6 @@
 block discarded – undo
33 33
         if (is_object($this->subject)) {
34 34
             return get_class($this->subject);
35 35
         }
36
-		return (string) $this->subject;
36
+		return (string)$this->subject;
37 37
 	}
38 38
 }
Please login to merge, or discard this patch.
src/Voter/ISingleVoterResult.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@
 block discarded – undo
5 5
 
6 6
 interface ISingleVoterResult extends IResult
7 7
 {
8
-    /**
9
-     * @return mixed
10
-     */
11
-    public function getReason();
8
+	/**
9
+	 * @return mixed
10
+	 */
11
+	public function getReason();
12 12
 }
13 13
\ No newline at end of file
Please login to merge, or discard this patch.