Completed
Pull Request — master (#4)
by Ondrej
01:56
created
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/VotingDecisionEnum.php 1 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/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.
src/Assembly/IVotingAssembly.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,10 +6,10 @@
 block discarded – undo
6 6
 interface IVotingAssembly
7 7
 {
8 8
 
9
-    /**
10
-     * @param mixed $votingSubject
11
-     * @param \SpareParts\Overseer\Context\IVotingContext $votingContext
12
-     * @return \SpareParts\Overseer\IVotingResult
13
-     */
14
-    public function commenceVote($votingSubject, IVotingContext $votingContext);
9
+	/**
10
+	 * @param mixed $votingSubject
11
+	 * @param \SpareParts\Overseer\Context\IVotingContext $votingContext
12
+	 * @return \SpareParts\Overseer\IVotingResult
13
+	 */
14
+	public function commenceVote($votingSubject, IVotingContext $votingContext);
15 15
 }
Please login to merge, or discard this patch.
src/AbstractVotingManager.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -6,42 +6,42 @@
 block discarded – undo
6 6
 
7 7
 abstract class AbstractVotingManager
8 8
 {
9
-    /**
10
-     * @var IVotingAbilityAwareAssembly[]
11
-     */
12
-    private $votingAssemblies;
13
-
14
-
15
-    /**
16
-     * VotingManager constructor.
17
-     * @param IVotingAbilityAwareAssembly[] $votingAssemblies
18
-     */
19
-    public function __construct(array $votingAssemblies)
20
-    {
21
-        $this->votingAssemblies = $votingAssemblies;
22
-    }
23
-
24
-
25
-    /**
26
-     * @param string $action
27
-     * @param mixed $votingSubject
28
-     * @param \SpareParts\Overseer\Context\IVotingContext $votingContext
29
-     * @return \SpareParts\Overseer\IVotingResult
30
-     * @throws \SpareParts\Overseer\InvalidVotingResultException
31
-     */
32
-    protected function innerVote($action, $votingSubject, IVotingContext $votingContext)
33
-    {
34
-        foreach ($this->votingAssemblies as $votingAssembly) {
35
-            if (!($votingAssembly instanceof IVotingAbilityAwareAssembly)) {
36
-                throw new InvalidArgumentException('Voting assemblies provided to voting manager must implement IVotingAbilityAwareAssembly interface!');
37
-            }
38
-
39
-            if ($votingAssembly->canVoteOn($action, $votingSubject, $votingContext)) {
40
-                return $votingAssembly->commenceVote($votingSubject, $votingContext);
41
-            }
42
-        }
43
-
44
-        throw new InvalidVotingResultException('No voting assembly for subject::action: '.
45
-            (string) $votingSubject.'::'.$action);
46
-    }
9
+	/**
10
+	 * @var IVotingAbilityAwareAssembly[]
11
+	 */
12
+	private $votingAssemblies;
13
+
14
+
15
+	/**
16
+	 * VotingManager constructor.
17
+	 * @param IVotingAbilityAwareAssembly[] $votingAssemblies
18
+	 */
19
+	public function __construct(array $votingAssemblies)
20
+	{
21
+		$this->votingAssemblies = $votingAssemblies;
22
+	}
23
+
24
+
25
+	/**
26
+	 * @param string $action
27
+	 * @param mixed $votingSubject
28
+	 * @param \SpareParts\Overseer\Context\IVotingContext $votingContext
29
+	 * @return \SpareParts\Overseer\IVotingResult
30
+	 * @throws \SpareParts\Overseer\InvalidVotingResultException
31
+	 */
32
+	protected function innerVote($action, $votingSubject, IVotingContext $votingContext)
33
+	{
34
+		foreach ($this->votingAssemblies as $votingAssembly) {
35
+			if (!($votingAssembly instanceof IVotingAbilityAwareAssembly)) {
36
+				throw new InvalidArgumentException('Voting assemblies provided to voting manager must implement IVotingAbilityAwareAssembly interface!');
37
+			}
38
+
39
+			if ($votingAssembly->canVoteOn($action, $votingSubject, $votingContext)) {
40
+				return $votingAssembly->commenceVote($votingSubject, $votingContext);
41
+			}
42
+		}
43
+
44
+		throw new InvalidVotingResultException('No voting assembly for subject::action: '.
45
+			(string) $votingSubject.'::'.$action);
46
+	}
47 47
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,6 +42,6 @@
 block discarded – undo
42 42
         }
43 43
 
44 44
         throw new InvalidVotingResultException('No voting assembly for subject::action: '.
45
-            (string) $votingSubject.'::'.$action);
45
+            (string)$votingSubject.'::'.$action);
46 46
     }
47 47
 }
Please login to merge, or discard this patch.
src/Context/IdentityContext.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -7,43 +7,43 @@
 block discarded – undo
7 7
 class IdentityContext implements IIdentityContext
8 8
 {
9 9
 
10
-    /**
11
-     * @var mixed
12
-     */
13
-    private $id;
14
-
15
-    /**
16
-     * @var string[]
17
-     */
18
-    private $roles;
19
-
20
-
21
-    /**
22
-     * VotingContext constructor.
23
-     * @param mixed $id
24
-     * @param string[] $roles
25
-     */
26
-    public function __construct($id, array $roles)
27
-    {
28
-        $this->id = $id;
29
-        $this->roles = $roles;
30
-    }
31
-
32
-
33
-    /**
34
-     * @return mixed
35
-     */
36
-    public function getId()
37
-    {
38
-        return $this->id;
39
-    }
40
-
41
-
42
-    /**
43
-     * @return string[]
44
-     */
45
-    public function getRoles()
46
-    {
47
-        return $this->roles;
48
-    }
10
+	/**
11
+	 * @var mixed
12
+	 */
13
+	private $id;
14
+
15
+	/**
16
+	 * @var string[]
17
+	 */
18
+	private $roles;
19
+
20
+
21
+	/**
22
+	 * VotingContext constructor.
23
+	 * @param mixed $id
24
+	 * @param string[] $roles
25
+	 */
26
+	public function __construct($id, array $roles)
27
+	{
28
+		$this->id = $id;
29
+		$this->roles = $roles;
30
+	}
31
+
32
+
33
+	/**
34
+	 * @return mixed
35
+	 */
36
+	public function getId()
37
+	{
38
+		return $this->id;
39
+	}
40
+
41
+
42
+	/**
43
+	 * @return string[]
44
+	 */
45
+	public function getRoles()
46
+	{
47
+		return $this->roles;
48
+	}
49 49
 }
Please login to merge, or discard this patch.
src/Context/IIdentityContext.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@
 block discarded – undo
7 7
 interface IIdentityContext extends IVotingContext
8 8
 {
9 9
 
10
-    /**
11
-     * @return string|int|null
12
-     */
13
-    public function getId();
10
+	/**
11
+	 * @return string|int|null
12
+	 */
13
+	public function getId();
14 14
 
15 15
 
16
-    /**
17
-     * @return string[]
18
-     */
19
-    public function getRoles();
16
+	/**
17
+	 * @return string[]
18
+	 */
19
+	public function getRoles();
20 20
 }
Please login to merge, or discard this patch.