Test Failed
Push — master ( c17565...48ddb2 )
by David
04:25
created
Service/CartManager.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -68,20 +68,20 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function getCartFromCustomer(SkuskuCustomerInterface $customer = null)
70 70
     {
71
-        if( !$customer ) {
71
+        if (!$customer) {
72 72
             $customer = $this->tokenStorage->getToken()->getUser();
73 73
         }
74 74
 
75 75
         // If the user is anon. the arg $customer is a string, so i check it
76
-        if( !($customer instanceof UserInterface) )
76
+        if (!($customer instanceof UserInterface))
77 77
             $customer = null;
78 78
 
79
-        if( !$this->allowAnonymous && !$customer )
79
+        if (!$this->allowAnonymous && !$customer)
80 80
             throw new AccessDeniedException("Anonymous users cannot buy");
81 81
 
82 82
         $cart = $this->em->getRepository('GGGGino\SkuskuCartBundle\Model\SkuskuCart')->findOneByCustomer($customer);
83 83
 
84
-        if( !$cart )
84
+        if (!$cart)
85 85
             $cart = $this->createNewCart($customer);
86 86
 
87 87
         return $cart;
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
      */
134 134
     public function addProductToCartForm(Request $request, FormInterface $form)
135 135
     {
136
-        if( $this->handled )
136
+        if ($this->handled)
137 137
             return;
138 138
 
139 139
         $form->handleRequest($request);
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
             /** @var SkuskuProductInterface $productReference */
150 150
             $productReference = $this->em->getReference(SkuskuProductInterface::class, $idProduct);
151 151
 
152
-            if( !($customer instanceof UserInterface) )
152
+            if (!($customer instanceof UserInterface))
153 153
                 $customer = null;
154 154
 
155
-            if( !$this->allowAnonymous && !$customer )
155
+            if (!$this->allowAnonymous && !$customer)
156 156
                 throw new AccessDeniedException("Anonymous users cannot buy");
157 157
 
158 158
             $this->addProductToCart($productReference, $quantity);
@@ -183,10 +183,10 @@  discard block
 block discarded – undo
183 183
         $this->em->persist($cart);
184 184
 
185 185
         /** @var SkuskuCartProduct $productCart */
186
-        if( $productCart = $cart->getProduct($product)->first() ){
186
+        if ($productCart = $cart->getProduct($product)->first()) {
187 187
             // @todo what?? $productCart->getQuantity() + $quantity
188 188
             $productCart->setQuantity($productCart->getQuantity() + $quantity);
189
-        }else{
189
+        } else {
190 190
             $productCart = new SkuskuCartProduct();
191 191
             $productCart->setProduct($product);
192 192
             $productCart->setQuantity($quantity);
Please login to merge, or discard this patch.
Braces   +19 added lines, -13 removed lines patch added patch discarded remove patch
@@ -73,16 +73,19 @@  discard block
 block discarded – undo
73 73
         }
74 74
 
75 75
         // If the user is anon. the arg $customer is a string, so i check it
76
-        if( !($customer instanceof UserInterface) )
77
-            $customer = null;
76
+        if( !($customer instanceof UserInterface) ) {
77
+                    $customer = null;
78
+        }
78 79
 
79
-        if( !$this->allowAnonymous && !$customer )
80
-            throw new AccessDeniedException("Anonymous users cannot buy");
80
+        if( !$this->allowAnonymous && !$customer ) {
81
+                    throw new AccessDeniedException("Anonymous users cannot buy");
82
+        }
81 83
 
82 84
         $cart = $this->em->getRepository('GGGGino\SkuskuCartBundle\Model\SkuskuCart')->findOneByCustomer($customer);
83 85
 
84
-        if( !$cart )
85
-            $cart = $this->createNewCart($customer);
86
+        if( !$cart ) {
87
+                    $cart = $this->createNewCart($customer);
88
+        }
86 89
 
87 90
         return $cart;
88 91
     }
@@ -133,8 +136,9 @@  discard block
 block discarded – undo
133 136
      */
134 137
     public function addProductToCartForm(Request $request, FormInterface $form)
135 138
     {
136
-        if( $this->handled )
137
-            return;
139
+        if( $this->handled ) {
140
+                    return;
141
+        }
138 142
 
139 143
         $form->handleRequest($request);
140 144
 
@@ -149,11 +153,13 @@  discard block
 block discarded – undo
149 153
             /** @var SkuskuProductInterface $productReference */
150 154
             $productReference = $this->em->getReference(SkuskuProductInterface::class, $idProduct);
151 155
 
152
-            if( !($customer instanceof UserInterface) )
153
-                $customer = null;
156
+            if( !($customer instanceof UserInterface) ) {
157
+                            $customer = null;
158
+            }
154 159
 
155
-            if( !$this->allowAnonymous && !$customer )
156
-                throw new AccessDeniedException("Anonymous users cannot buy");
160
+            if( !$this->allowAnonymous && !$customer ) {
161
+                            throw new AccessDeniedException("Anonymous users cannot buy");
162
+            }
157 163
 
158 164
             $this->addProductToCart($productReference, $quantity);
159 165
         }
@@ -186,7 +192,7 @@  discard block
 block discarded – undo
186 192
         if( $productCart = $cart->getProduct($product)->first() ){
187 193
             // @todo what?? $productCart->getQuantity() + $quantity
188 194
             $productCart->setQuantity($productCart->getQuantity() + $quantity);
189
-        }else{
195
+        } else{
190 196
             $productCart = new SkuskuCartProduct();
191 197
             $productCart->setProduct($product);
192 198
             $productCart->setQuantity($quantity);
Please login to merge, or discard this patch.