@@ -71,17 +71,13 @@ private function decideAffirmative(TokenInterface $token, array $attributes, $ob
7171 $ deny = 0 ;
7272 foreach ($ this ->voters as $ voter ) {
7373 $ result = $ voter ->vote ($ token , $ object , $ attributes );
74- switch ($ result ) {
75- case VoterInterface::ACCESS_GRANTED :
76- return true ;
7774
78- case VoterInterface::ACCESS_DENIED :
79- ++$ deny ;
80-
81- break ;
75+ if (VoterInterface::ACCESS_GRANTED === $ result ) {
76+ return true ;
77+ }
8278
83- default :
84- break ;
79+ if (VoterInterface:: ACCESS_DENIED === $ result ) {
80+ ++ $ deny ;
8581 }
8682 }
8783
@@ -113,16 +109,10 @@ private function decideConsensus(TokenInterface $token, array $attributes, $obje
113109 foreach ($ this ->voters as $ voter ) {
114110 $ result = $ voter ->vote ($ token , $ object , $ attributes );
115111
116- switch ($ result ) {
117- case VoterInterface::ACCESS_GRANTED :
118- ++$ grant ;
119-
120- break ;
121-
122- case VoterInterface::ACCESS_DENIED :
123- ++$ deny ;
124-
125- break ;
112+ if (VoterInterface::ACCESS_GRANTED === $ result ) {
113+ ++$ grant ;
114+ } elseif (VoterInterface::ACCESS_DENIED === $ result ) {
115+ ++$ deny ;
126116 }
127117 }
128118
@@ -154,17 +144,12 @@ private function decideUnanimous(TokenInterface $token, array $attributes, $obje
154144 foreach ($ attributes as $ attribute ) {
155145 $ result = $ voter ->vote ($ token , $ object , [$ attribute ]);
156146
157- switch ($ result ) {
158- case VoterInterface::ACCESS_GRANTED :
159- ++$ grant ;
160-
161- break ;
162-
163- case VoterInterface::ACCESS_DENIED :
164- return false ;
147+ if (VoterInterface::ACCESS_DENIED === $ result ) {
148+ return false ;
149+ }
165150
166- default :
167- break ;
151+ if (VoterInterface:: ACCESS_GRANTED === $ result ) {
152+ ++ $ grant ;
168153 }
169154 }
170155 }
0 commit comments