Completed
Pull Request — master (#4)
by Ondrej
01:56
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.
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.
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
 }
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/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.
src/Voter/SingleVoterResult.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -6,42 +6,42 @@
 block discarded – undo
6 6
 class SingleVoterResult implements ISingleVoterResult
7 7
 {
8 8
 
9
-    /**
10
-     * @var VotingDecisionEnum
11
-     */
12
-    private $decision;
13
-
14
-    /**
15
-     * @var mixed
16
-     */
17
-    private $reason;
18
-
19
-
20
-    /**
21
-     * SingleVoterResult constructor.
22
-     * @param VotingDecisionEnum $decision
23
-     * @param mixed $reason
24
-     */
25
-    public function __construct(VotingDecisionEnum $decision, $reason = null)
26
-    {
27
-        $this->decision = $decision;
28
-        $this->reason = $reason;
29
-    }
30
-
31
-
32
-    /**
33
-     * @return VotingDecisionEnum
34
-     */
35
-    public function getDecision()
36
-    {
37
-        return $this->decision;
38
-    }
39
-
40
-    /**
41
-     * @return mixed
42
-     */
43
-    public function getReason()
44
-    {
45
-        return $this->reason;
46
-    }
9
+	/**
10
+	 * @var VotingDecisionEnum
11
+	 */
12
+	private $decision;
13
+
14
+	/**
15
+	 * @var mixed
16
+	 */
17
+	private $reason;
18
+
19
+
20
+	/**
21
+	 * SingleVoterResult constructor.
22
+	 * @param VotingDecisionEnum $decision
23
+	 * @param mixed $reason
24
+	 */
25
+	public function __construct(VotingDecisionEnum $decision, $reason = null)
26
+	{
27
+		$this->decision = $decision;
28
+		$this->reason = $reason;
29
+	}
30
+
31
+
32
+	/**
33
+	 * @return VotingDecisionEnum
34
+	 */
35
+	public function getDecision()
36
+	{
37
+		return $this->decision;
38
+	}
39
+
40
+	/**
41
+	 * @return mixed
42
+	 */
43
+	public function getReason()
44
+	{
45
+		return $this->reason;
46
+	}
47 47
 }
48 48
\ No newline at end of file
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
 }
Please login to merge, or discard this patch.
src/Assembly/VotingAbilityAwareAssembly.php 2 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -10,64 +10,64 @@
 block discarded – undo
10 10
 class VotingAbilityAwareAssembly extends VotingAssembly implements IVotingAbilityAwareAssembly
11 11
 {
12 12
 
13
-    /**
14
-     * @var string
15
-     */
16
-    protected $subjectClassName;
13
+	/**
14
+	 * @var string
15
+	 */
16
+	protected $subjectClassName;
17 17
 
18
-    /**
19
-     * @var string
20
-     */
21
-    protected $contextClassName;
18
+	/**
19
+	 * @var string
20
+	 */
21
+	protected $contextClassName;
22 22
 
23
-    /**
24
-     * @var string[]
25
-     */
26
-    protected $actionList;
23
+	/**
24
+	 * @var string[]
25
+	 */
26
+	protected $actionList;
27 27
 
28 28
 
29
-    /**
30
-     * @param \SpareParts\Overseer\StrategyEnum $strategy
31
-     * @param IVoter[] $voters
32
-     * @param string|string[] $actions
33
-     * @param string $contextClassName
34
-     * @param string $subjectClassName
35
-     */
36
-    public function __construct(
37
-        StrategyEnum $strategy,
38
-        array $voters,
39
-        $actions = null,
40
-        $contextClassName = IIdentityContext::class,
41
-        $subjectClassName = null
42
-    ) {
43
-        parent::__construct($strategy, $voters);
29
+	/**
30
+	 * @param \SpareParts\Overseer\StrategyEnum $strategy
31
+	 * @param IVoter[] $voters
32
+	 * @param string|string[] $actions
33
+	 * @param string $contextClassName
34
+	 * @param string $subjectClassName
35
+	 */
36
+	public function __construct(
37
+		StrategyEnum $strategy,
38
+		array $voters,
39
+		$actions = null,
40
+		$contextClassName = IIdentityContext::class,
41
+		$subjectClassName = null
42
+	) {
43
+		parent::__construct($strategy, $voters);
44 44
 
45
-        $this->actionList = (array) $actions;
46
-        $this->subjectClassName = $subjectClassName;
47
-        $this->contextClassName = $contextClassName;
48
-    }
45
+		$this->actionList = (array) $actions;
46
+		$this->subjectClassName = $subjectClassName;
47
+		$this->contextClassName = $contextClassName;
48
+	}
49 49
 
50 50
 
51
-    /**
52
-     * @param string $actionName
53
-     * @param object $subject
54
-     * @param \SpareParts\Overseer\Context\IVotingContext $context
55
-     * @return bool
56
-     */
57
-    public function canVoteOn($actionName, $subject, IVotingContext $context)
58
-    {
59
-        if ($this->subjectClassName && !($subject instanceof $this->subjectClassName)) {
60
-            return false;
61
-        }
51
+	/**
52
+	 * @param string $actionName
53
+	 * @param object $subject
54
+	 * @param \SpareParts\Overseer\Context\IVotingContext $context
55
+	 * @return bool
56
+	 */
57
+	public function canVoteOn($actionName, $subject, IVotingContext $context)
58
+	{
59
+		if ($this->subjectClassName && !($subject instanceof $this->subjectClassName)) {
60
+			return false;
61
+		}
62 62
 
63
-        if ($this->contextClassName && !($context instanceof $this->contextClassName)) {
64
-            return false;
65
-        }
63
+		if ($this->contextClassName && !($context instanceof $this->contextClassName)) {
64
+			return false;
65
+		}
66 66
 
67
-        if ($this->actionList && !in_array($actionName, $this->actionList)) {
68
-            return false;
69
-        }
70
-        return true;
71
-    }
67
+		if ($this->actionList && !in_array($actionName, $this->actionList)) {
68
+			return false;
69
+		}
70
+		return true;
71
+	}
72 72
 
73 73
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
     ) {
43 43
         parent::__construct($strategy, $voters);
44 44
 
45
-        $this->actionList = (array) $actions;
45
+        $this->actionList = (array)$actions;
46 46
         $this->subjectClassName = $subjectClassName;
47 47
         $this->contextClassName = $contextClassName;
48 48
     }
Please login to merge, or discard this patch.
src/Assembly/VotingAssembly.php 2 patches
Indentation   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -12,107 +12,107 @@
 block discarded – undo
12 12
 class VotingAssembly implements IVotingAssembly
13 13
 {
14 14
 
15
-    /**
16
-     * @var StrategyEnum
17
-     */
18
-    private $strategy;
19
-
20
-    /**
21
-     * @var IVoter[]
22
-     */
23
-    private $voters;
24
-
25
-
26
-    /**
27
-     * VotingAssembly constructor.
28
-     * @param StrategyEnum $strategy
29
-     * @param \SpareParts\Overseer\Voter\IVoter[] $voters
30
-     */
31
-    public function __construct(StrategyEnum $strategy, array $voters)
32
-    {
33
-        $this->strategy = $strategy;
34
-        $this->voters = $voters;
35
-    }
36
-
37
-
38
-    /**
39
-     * @param mixed $votingSubject
40
-     * @param \SpareParts\Overseer\Context\IVotingContext $votingContext
41
-     * @return null|\SpareParts\Overseer\IVotingResult
42
-     * @throws \SpareParts\Overseer\InvalidVotingResultException
43
-     */
44
-    public function commenceVote($votingSubject, IVotingContext $votingContext)
45
-    {
46
-        $result = null;
47
-        switch ($this->strategy) {
48
-            case StrategyEnum::FIRST_VOTE_DECIDES():
49
-                return $this->strategyFirstVoteDecides($votingSubject, $votingContext);
50
-
51
-            case StrategyEnum::ALLOW_UNLESS_DENIED():
52
-                return $this->strategyAllowUnlessDenied($votingSubject, $votingContext);
53
-
54
-            case StrategyEnum::DENY_UNLESS_ALLOWED():
55
-                return $this->strategyDenyUnlessAllowed($votingSubject, $votingContext);
56
-
57
-            default:
58
-                throw new InvalidVotingResultException('Unable to decide on result, invalid strategy: '.$this->strategy);
59
-        }
60
-    }
61
-
62
-
63
-    /**
64
-     * @param mixed $votingSubject
65
-     * @param \SpareParts\Overseer\Context\IVotingContext $votingContext
66
-     * @return \SpareParts\Overseer\IVotingResult
67
-     * @throws \SpareParts\Overseer\InvalidVotingResultException
68
-     */
69
-    private function strategyFirstVoteDecides($votingSubject, IVotingContext $votingContext)
70
-    {
71
-        foreach ($this->voters as $voter) {
72
-            if (($lastResult = $voter->vote($votingSubject, $votingContext)) !== null) {
73
-                return new VotingResult($lastResult->getDecision(), [$lastResult]);
74
-            }
75
-        }
76
-        throw new InvalidVotingResultException('Voting assembly did not decide on any result!');
77
-    }
78
-
79
-
80
-    /**
81
-     * @param mixed $votingSubject
82
-     * @param \SpareParts\Overseer\Context\IVotingContext $votingContext
83
-     * @return \SpareParts\Overseer\IVotingResult
84
-     */
85
-    private function strategyAllowUnlessDenied($votingSubject, IVotingContext $votingContext)
86
-    {
87
-        $results = [];
88
-        foreach ($this->voters as $name => $voter) {
89
-            if (($lastResult = $voter->vote($votingSubject, $votingContext)) !== null) {
90
-                $results[] = $lastResult;
91
-                if ($lastResult->getDecision() === VotingDecisionEnum::DENIED()) {
92
-                    return new VotingResult(VotingDecisionEnum::DENIED(), $results);
93
-                }
94
-            }
95
-        }
96
-        return new VotingResult(VotingDecisionEnum::ALLOWED(), $results);
97
-    }
98
-
99
-
100
-    /**
101
-     * @param mixed $votingSubject
102
-     * @param \SpareParts\Overseer\Context\IVotingContext $votingContext
103
-     * @return \SpareParts\Overseer\IVotingResult
104
-     */
105
-    private function strategyDenyUnlessAllowed($votingSubject, IVotingContext $votingContext)
106
-    {
107
-        $results = [];
108
-        foreach ($this->voters as $name => $voter) {
109
-            if (($lastResult = $voter->vote($votingSubject, $votingContext)) !== null) {
110
-                $results[] = $lastResult;
111
-                if ($lastResult->getDecision() === VotingDecisionEnum::ALLOWED()) {
112
-                    return new VotingResult(VotingDecisionEnum::ALLOWED(), $results);
113
-                }
114
-            }
115
-        }
116
-        return new VotingResult(VotingDecisionEnum::DENIED(), $results);
117
-    }
15
+	/**
16
+	 * @var StrategyEnum
17
+	 */
18
+	private $strategy;
19
+
20
+	/**
21
+	 * @var IVoter[]
22
+	 */
23
+	private $voters;
24
+
25
+
26
+	/**
27
+	 * VotingAssembly constructor.
28
+	 * @param StrategyEnum $strategy
29
+	 * @param \SpareParts\Overseer\Voter\IVoter[] $voters
30
+	 */
31
+	public function __construct(StrategyEnum $strategy, array $voters)
32
+	{
33
+		$this->strategy = $strategy;
34
+		$this->voters = $voters;
35
+	}
36
+
37
+
38
+	/**
39
+	 * @param mixed $votingSubject
40
+	 * @param \SpareParts\Overseer\Context\IVotingContext $votingContext
41
+	 * @return null|\SpareParts\Overseer\IVotingResult
42
+	 * @throws \SpareParts\Overseer\InvalidVotingResultException
43
+	 */
44
+	public function commenceVote($votingSubject, IVotingContext $votingContext)
45
+	{
46
+		$result = null;
47
+		switch ($this->strategy) {
48
+			case StrategyEnum::FIRST_VOTE_DECIDES():
49
+				return $this->strategyFirstVoteDecides($votingSubject, $votingContext);
50
+
51
+			case StrategyEnum::ALLOW_UNLESS_DENIED():
52
+				return $this->strategyAllowUnlessDenied($votingSubject, $votingContext);
53
+
54
+			case StrategyEnum::DENY_UNLESS_ALLOWED():
55
+				return $this->strategyDenyUnlessAllowed($votingSubject, $votingContext);
56
+
57
+			default:
58
+				throw new InvalidVotingResultException('Unable to decide on result, invalid strategy: '.$this->strategy);
59
+		}
60
+	}
61
+
62
+
63
+	/**
64
+	 * @param mixed $votingSubject
65
+	 * @param \SpareParts\Overseer\Context\IVotingContext $votingContext
66
+	 * @return \SpareParts\Overseer\IVotingResult
67
+	 * @throws \SpareParts\Overseer\InvalidVotingResultException
68
+	 */
69
+	private function strategyFirstVoteDecides($votingSubject, IVotingContext $votingContext)
70
+	{
71
+		foreach ($this->voters as $voter) {
72
+			if (($lastResult = $voter->vote($votingSubject, $votingContext)) !== null) {
73
+				return new VotingResult($lastResult->getDecision(), [$lastResult]);
74
+			}
75
+		}
76
+		throw new InvalidVotingResultException('Voting assembly did not decide on any result!');
77
+	}
78
+
79
+
80
+	/**
81
+	 * @param mixed $votingSubject
82
+	 * @param \SpareParts\Overseer\Context\IVotingContext $votingContext
83
+	 * @return \SpareParts\Overseer\IVotingResult
84
+	 */
85
+	private function strategyAllowUnlessDenied($votingSubject, IVotingContext $votingContext)
86
+	{
87
+		$results = [];
88
+		foreach ($this->voters as $name => $voter) {
89
+			if (($lastResult = $voter->vote($votingSubject, $votingContext)) !== null) {
90
+				$results[] = $lastResult;
91
+				if ($lastResult->getDecision() === VotingDecisionEnum::DENIED()) {
92
+					return new VotingResult(VotingDecisionEnum::DENIED(), $results);
93
+				}
94
+			}
95
+		}
96
+		return new VotingResult(VotingDecisionEnum::ALLOWED(), $results);
97
+	}
98
+
99
+
100
+	/**
101
+	 * @param mixed $votingSubject
102
+	 * @param \SpareParts\Overseer\Context\IVotingContext $votingContext
103
+	 * @return \SpareParts\Overseer\IVotingResult
104
+	 */
105
+	private function strategyDenyUnlessAllowed($votingSubject, IVotingContext $votingContext)
106
+	{
107
+		$results = [];
108
+		foreach ($this->voters as $name => $voter) {
109
+			if (($lastResult = $voter->vote($votingSubject, $votingContext)) !== null) {
110
+				$results[] = $lastResult;
111
+				if ($lastResult->getDecision() === VotingDecisionEnum::ALLOWED()) {
112
+					return new VotingResult(VotingDecisionEnum::ALLOWED(), $results);
113
+				}
114
+			}
115
+		}
116
+		return new VotingResult(VotingDecisionEnum::DENIED(), $results);
117
+	}
118 118
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     {
71 71
         foreach ($this->voters as $voter) {
72 72
             if (($lastResult = $voter->vote($votingSubject, $votingContext)) !== null) {
73
-                return new VotingResult($lastResult->getDecision(), [$lastResult]);
73
+                return new VotingResult($lastResult->getDecision(), [ $lastResult ]);
74 74
             }
75 75
         }
76 76
         throw new InvalidVotingResultException('Voting assembly did not decide on any result!');
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
      */
85 85
     private function strategyAllowUnlessDenied($votingSubject, IVotingContext $votingContext)
86 86
     {
87
-        $results = [];
87
+        $results = [ ];
88 88
         foreach ($this->voters as $name => $voter) {
89 89
             if (($lastResult = $voter->vote($votingSubject, $votingContext)) !== null) {
90
-                $results[] = $lastResult;
90
+                $results[ ] = $lastResult;
91 91
                 if ($lastResult->getDecision() === VotingDecisionEnum::DENIED()) {
92 92
                     return new VotingResult(VotingDecisionEnum::DENIED(), $results);
93 93
                 }
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
      */
105 105
     private function strategyDenyUnlessAllowed($votingSubject, IVotingContext $votingContext)
106 106
     {
107
-        $results = [];
107
+        $results = [ ];
108 108
         foreach ($this->voters as $name => $voter) {
109 109
             if (($lastResult = $voter->vote($votingSubject, $votingContext)) !== null) {
110
-                $results[] = $lastResult;
110
+                $results[ ] = $lastResult;
111 111
                 if ($lastResult->getDecision() === VotingDecisionEnum::ALLOWED()) {
112 112
                     return new VotingResult(VotingDecisionEnum::ALLOWED(), $results);
113 113
                 }
Please login to merge, or discard this patch.
src/Assembly/IVotingAbilityAwareAssembly.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@
 block discarded – undo
13 13
 {
14 14
 
15 15
 
16
-    /**
17
-     * @param string $actionName
18
-     * @param mixed $subject
19
-     * @param \SpareParts\Overseer\Context\IVotingContext $context
20
-     * @return bool
21
-     */
22
-    public function canVoteOn($actionName, $subject, IVotingContext $context);
16
+	/**
17
+	 * @param string $actionName
18
+	 * @param mixed $subject
19
+	 * @param \SpareParts\Overseer\Context\IVotingContext $context
20
+	 * @return bool
21
+	 */
22
+	public function canVoteOn($actionName, $subject, IVotingContext $context);
23 23
 }
Please login to merge, or discard this patch.