Completed
Push — master ( b71e6c...5e9553 )
by
unknown
156:05 queued 101:02
created
back/src/KI/UserBundle/Entity/CoreUser.php 1 patch
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
     /**
219 219
      * Add group
220 220
      *
221
-     * @param \KI\UserBundle\Entity\User $group
222
-     * @return Comment
221
+     * @param Group $group
222
+     * @return CoreUser
223 223
      */
224 224
     public function addGroupUser(\KI\UserBundle\Entity\Group $group)
225 225
     {
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
     /**
233 233
      * Remove group
234 234
      *
235
-     * @param \KI\UserBundle\Entity\User $group
235
+     * @param Group $group
236 236
      */
237 237
     public function removeGroupUser(\KI\UserBundle\Entity\Group $group)
238 238
     {
Please login to merge, or discard this patch.
back/src/KI/UserBundle/Repository/UserRepository.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
      */
18 18
     public function findFollowedEvents($userId, $limit = null, $page = null)
19 19
     {
20
-         $query = $this->getEntityManager()->createQuery('SELECT event FROM
20
+            $query = $this->getEntityManager()->createQuery('SELECT event FROM
21 21
             KIPublicationBundle:Event event,
22 22
             KIUserBundle:Club club,
23 23
             KIUserBundle:User user
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
         ')
34 34
             ->setParameter('userId', $userId);
35 35
 
36
-        if($limit !== null && $limit > 0) {
36
+        if ($limit !== null && $limit > 0) {
37 37
             $query->setMaxResults($limit);
38 38
 
39 39
             if ($page !== null && $page > 0)
40
-                $query->setFirstResult(($page - 1) * $limit);
40
+                $query->setFirstResult(($page - 1)*$limit);
41 41
         }
42 42
 
43 43
         return $query->getResult();
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
     public function getOnlineUsers($delay = 30) {
102 102
         return $this->createQueryBuilder('u')
103 103
             ->where('u.lastConnect > :date')
104
-            ->setParameter('date', time() - $delay * 60)
104
+            ->setParameter('date', time() - $delay*60)
105 105
             ->getQuery()
106 106
             ->getResult();
107 107
     }
Please login to merge, or discard this patch.
back/src/KI/UserBundle/Command/FacegameAchievementsCommand.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,23 +47,23 @@
 block discarded – undo
47 47
             $wrongAnswers = $facegame->getWrongAnswers();
48 48
             $duration = $facegame->getDuration();
49 49
 
50
-            if ($wrongAnswers == 0 && $promoGame == $promoUser - 1 && $duration < 60 * 1000) {
50
+            if ($wrongAnswers == 0 && $promoGame == $promoUser - 1 && $duration < 60*1000) {
51 51
 
52 52
                 $achievementCheck = new AchievementCheckEvent(Achievement::GAME_BEFORE, $user);
53 53
                 $dispatcher->dispatch('upont.achievement', $achievementCheck);
54 54
 
55
-            } else if ($wrongAnswers == 0 && $promoGame == $promoUser && $duration < 60 * 1000) {
55
+            } else if ($wrongAnswers == 0 && $promoGame == $promoUser && $duration < 60*1000) {
56 56
 
57 57
                 $achievementCheck = new AchievementCheckEvent(Achievement::GAME_SELF, $user);
58 58
                 $dispatcher->dispatch('upont.achievement', $achievementCheck);
59 59
 
60
-            } else if ($wrongAnswers == 0 && $promoGame == $promoUser + 1 && $duration < 60 * 1000) {
60
+            } else if ($wrongAnswers == 0 && $promoGame == $promoUser + 1 && $duration < 60*1000) {
61 61
 
62 62
                 $achievementCheck = new AchievementCheckEvent(Achievement::GAME_NEXT, $user);
63 63
                 $dispatcher->dispatch('upont.achievement', $achievementCheck);
64 64
 
65 65
             }
66
-            if ($wrongAnswers == 0 && $promoGame < $promoUser && $facegame->getHardcore() && $duration < 60 * 1000) {
66
+            if ($wrongAnswers == 0 && $promoGame < $promoUser && $facegame->getHardcore() && $duration < 60*1000) {
67 67
 
68 68
                 $achievementCheck = new AchievementCheckEvent(Achievement::GAME_OLD, $user);
69 69
                 $dispatcher->dispatch('upont.achievement', $achievementCheck);
Please login to merge, or discard this patch.
back/src/KI/CoreBundle/Helper/FormHelper.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -5,9 +5,7 @@
 block discarded – undo
5 5
 use Doctrine\ORM\EntityManager;
6 6
 use Symfony\Bundle\FrameworkBundle\Routing\Router;
7 7
 use Symfony\Component\Form\FormFactory;
8
-use Symfony\Component\HttpFoundation\JsonResponse;
9 8
 use Symfony\Component\HttpFoundation\RequestStack;
10
-use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
11 9
 
12 10
 // Valide les formulaires pour une entité et affiche la réponse à la demande
13 11
 class FormHelper
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
     public function formData($item, $method, $flush = true)
39 39
     {
40 40
         // On devine le formulaire à partir du chemin de la classe
41
-        $formName = str_replace('Entity', 'Form', get_class($item)) . 'Type';
41
+        $formName = str_replace('Entity', 'Form', get_class($item)).'Type';
42 42
         $form = $this->formFactory->create($formName, $item, ['method' => $method]);
43 43
         $form->handleRequest($this->request);
44 44
         $code = 400;
Please login to merge, or discard this patch.
back/src/KI/CoreBundle/Helper/PaginateHelper.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,6 @@
 block discarded – undo
4 4
 
5 5
 use Doctrine\ORM\EntityManager;
6 6
 use Doctrine\ORM\EntityRepository;
7
-use Symfony\Component\HttpFoundation\JsonResponse;
8 7
 use Symfony\Component\HttpFoundation\RequestStack;
9 8
 use Symfony\Component\HttpFoundation\Response;
10 9
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -63,23 +63,23 @@
 block discarded – undo
63 63
 
64 64
         // On compte le nombre total d'entrées dans la BDD
65 65
         $queryBuilder->select('count(o.id)');
66
-        foreach ($findBy as $key => $values){
66
+        foreach ($findBy as $key => $values) {
67 67
             $andCount = 0;
68 68
             $and = '';
69
-            foreach($values as $value){
70
-                if($andCount > 0){
69
+            foreach ($values as $value) {
70
+                if ($andCount > 0) {
71 71
                     $and .= ' OR ';
72 72
                 }
73
-                $and .= 'o.' . $key . ' = :' . $key . $andCount;
74
-                $queryBuilder->setParameter($key . $andCount, $value);
73
+                $and .= 'o.'.$key.' = :'.$key.$andCount;
74
+                $queryBuilder->setParameter($key.$andCount, $value);
75 75
 
76 76
                 $andCount++;
77 77
             }
78 78
             $queryBuilder->andWhere($and);
79 79
         }
80 80
 
81
-        foreach($sortBy as $field => $order){
82
-            $queryBuilder->addOrderBy('o.' . $field, $order);
81
+        foreach ($sortBy as $field => $order) {
82
+            $queryBuilder->addOrderBy('o.'.$field, $order);
83 83
         }
84 84
 
85 85
         $count = $queryBuilder->getQuery()->getSingleScalarResult();
Please login to merge, or discard this patch.
back/src/KI/UserBundle/Controller/UsersController.php 3 patches
Unused Use Statements   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,6 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 namespace KI\UserBundle\Controller;
4 4
 
5
+use Exception;
5 6
 use KI\CoreBundle\Controller\ResourceController;
6 7
 use KI\UserBundle\Entity\Achievement;
7 8
 use KI\UserBundle\Entity\User;
@@ -13,7 +14,6 @@  discard block
 block discarded – undo
13 14
 use Symfony\Component\HttpFoundation\Request;
14 15
 use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
15 16
 use Symfony\Component\Security\Core\Exception\AccessDeniedException;
16
-use Exception;
17 17
 
18 18
 class UsersController extends ResourceController
19 19
 {
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
             throw new BadRequestHttpException('Cet utilisateur existe déjà.');
222 222
 
223 223
         // Si le login existe déjà, on ajoute une lettre du prénom
224
-        $login = strtolower(str_replace(' ', '-', substr($this->stripAccents($lastName), 0, 7) . $this->stripAccents($firstName)[0]));
224
+        $login = strtolower(str_replace(' ', '-', substr($this->stripAccents($lastName), 0, 7).$this->stripAccents($firstName)[0]));
225 225
         $i = 1;
226 226
         while (count($repo->findByUsername($login)) > 0) {
227 227
             if (isset($firstName[$i]))
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
         }
279 279
 
280 280
         // On récupère le contenu du fichier
281
-        $path = __DIR__ . '/../../../../web/uploads/tmp/';
281
+        $path = __DIR__.'/../../../../web/uploads/tmp/';
282 282
         $file->move($path, 'users.list');
283
-        $list = fopen($path . 'users.list', 'r+');
283
+        $list = fopen($path.'users.list', 'r+');
284 284
         if ($list === false)
285 285
             throw new BadRequestHttpException('Erreur lors de l\'upload du fichier');
286 286
 
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
         while (!feof($list)) {
291 291
             // On enlève le caractère de fin de ligne
292 292
             $line = str_replace(["\r", "\n"], ['', ''], fgets($list));
293
-            if(empty($line))
293
+            if (empty($line))
294 294
                 continue;
295 295
 
296 296
             $gender = $login = $firstName = $lastName = $email = $promo = $department = $origin = null;
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
                 $e[] = 'Adresse mail non utilisable';
307 307
 
308 308
             if (count($e) > 0) {
309
-                $fails[] = $line . ' : ' . implode(', ', $e);
309
+                $fails[] = $line.' : '.implode(', ', $e);
310 310
             } else {
311 311
 
312 312
                 /**
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
                 }
334 334
                 $user->setGender($gender);
335 335
 
336
-                $success[] = $firstName . ' ' . $lastName;
336
+                $success[] = $firstName.' '.$lastName;
337 337
             }
338 338
         }
339 339
 
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -343,6 +343,9 @@
 block discarded – undo
343 343
         ], 201);
344 344
     }
345 345
 
346
+    /**
347
+     * @return string
348
+     */
346 349
     private function stripAccents($string)
347 350
     {
348 351
         return str_replace(
Please login to merge, or discard this patch.
back/src/KI/UserBundle/Factory/UserFactory.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -18,6 +18,12 @@
 block discarded – undo
18 18
         $this->eventDispatcher = $eventDispatcher;
19 19
     }
20 20
 
21
+    /**
22
+     * @param string $key
23
+     * @param string $default_value
24
+     *
25
+     * @return string
26
+     */
21 27
     private function array_value($array, $key, $default_value = null)
22 28
     {
23 29
         if (!is_array($array))
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,8 +48,8 @@
 block discarded – undo
48 48
         $user->setEmail($email);
49 49
 
50 50
         $password = $this->array_value($attributes, 'password');
51
-        if(!$password) {
52
-            $password = substr(str_shuffle(strtolower(sha1(rand() . time() . 'salt'))), 0, 8);
51
+        if (!$password) {
52
+            $password = substr(str_shuffle(strtolower(sha1(rand().time().'salt'))), 0, 8);
53 53
             $attributes['password'] = $password;
54 54
         }
55 55
 
Please login to merge, or discard this patch.
back/src/KI/UserBundle/Listener/FacebookImportUserRegistrationListener.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,6 @@
 block discarded – undo
6 6
 use KI\CoreBundle\Service\CurlService;
7 7
 use KI\CoreBundle\Service\ImageService;
8 8
 use KI\UserBundle\Entity\User;
9
-
10 9
 use KI\UserBundle\Event\UserRegistrationEvent;
11 10
 
12 11
 class FacebookImportUserRegistrationListener
Please login to merge, or discard this patch.
Switch Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -33,26 +33,26 @@
 block discarded – undo
33 33
         switch ($user->getPromo()) {
34 34
             // Attention, toujours préciser l'id facebook de la promo d'après
35 35
             // pour avoir les étrangers
36
-            case '015':
37
-                $id = '359646667495742';
38
-                break;  // Wei't spirit
39
-            case '016':
40
-                $id = '1451446761806184';
41
-                break; // Wei't the phoque
42
-            case '017':
43
-                $id = '737969042997359';
44
-                break;  // F'wei'ght Club
45
-            case '018':
46
-                $id = '1739424532975028';
47
-                break;  // WEI'STED
48
-            case '019':
49
-                $id = '313192685791329';
50
-                break;  // WEI'T FOR IT
51
-            case '020':
52
-                $id = '313192685791329';
53
-                break;  // WEI'T FOR IT
54
-            default:
55
-                return;
36
+        case '015':
37
+            $id = '359646667495742';
38
+            break;  // Wei't spirit
39
+        case '016':
40
+            $id = '1451446761806184';
41
+            break; // Wei't the phoque
42
+        case '017':
43
+            $id = '737969042997359';
44
+            break;  // F'wei'ght Club
45
+        case '018':
46
+            $id = '1739424532975028';
47
+            break;  // WEI'STED
48
+        case '019':
49
+            $id = '313192685791329';
50
+            break;  // WEI'T FOR IT
51
+        case '020':
52
+            $id = '313192685791329';
53
+            break;  // WEI'T FOR IT
54
+        default:
55
+            return;
56 56
         }
57 57
 
58 58
         // On récupère la liste des membres
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
         $this->fbToken = $facebookToken;
25 25
     }
26 26
 
27
-    public function facebookImport(UserRegistrationEvent $event){
27
+    public function facebookImport(UserRegistrationEvent $event) {
28 28
         $user = $event->getUser();
29 29
 
30
-        $token = '?access_token=' . $this->fbToken;
30
+        $token = '?access_token='.$this->fbToken;
31 31
 
32 32
         // Ids des différents groupes facebook
33 33
         switch ($user->getPromo()) {
@@ -35,29 +35,29 @@  discard block
 block discarded – undo
35 35
             // pour avoir les étrangers
36 36
             case '015':
37 37
                 $id = '359646667495742';
38
-                break;  // Wei't spirit
38
+                break; // Wei't spirit
39 39
             case '016':
40 40
                 $id = '1451446761806184';
41 41
                 break; // Wei't the phoque
42 42
             case '017':
43 43
                 $id = '737969042997359';
44
-                break;  // F'wei'ght Club
44
+                break; // F'wei'ght Club
45 45
             case '018':
46 46
                 $id = '1739424532975028';
47
-                break;  // WEI'STED
47
+                break; // WEI'STED
48 48
             case '019':
49 49
                 $id = '313192685791329';
50
-                break;  // WEI'T FOR IT
50
+                break; // WEI'T FOR IT
51 51
             case '020':
52 52
                 $id = '313192685791329';
53
-                break;  // WEI'T FOR IT
53
+                break; // WEI'T FOR IT
54 54
             default:
55 55
                 return;
56 56
         }
57 57
 
58 58
         // On récupère la liste des membres
59 59
         $baseUrl = 'https://graph.facebook.com/v2.10';
60
-        $data = json_decode($this->curlService->curl($baseUrl . '/' . $id . '/members' . $token . '&limit=10000'), true);
60
+        $data = json_decode($this->curlService->curl($baseUrl.'/'.$id.'/members'.$token.'&limit=10000'), true);
61 61
 
62 62
         $bestMatch = null;
63 63
         $bestPercent = -1;
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
         }
71 71
 
72 72
         if ($bestPercent > 85) {
73
-            $url = '/' . $bestMatch['id'] . '/picture' . $token . '&width=9999&redirect=false';
74
-            $dataImage = json_decode($this->curlService->curl($baseUrl . $url), true);
73
+            $url = '/'.$bestMatch['id'].'/picture'.$token.'&width=9999&redirect=false';
74
+            $dataImage = json_decode($this->curlService->curl($baseUrl.$url), true);
75 75
             $image = $this->imageService->upload($dataImage['data']['url'], true);
76 76
             $user->setImage($image);
77 77
         }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     private function isSimilar(User $user, array $member)
85 85
     {
86 86
         $percent = 0;
87
-        similar_text($user->getFirstName() . ' ' . $user->getLastName(), $member['name'], $percent);
87
+        similar_text($user->getFirstName().' '.$user->getLastName(), $member['name'], $percent);
88 88
         return $percent;
89 89
     }
90 90
 }
Please login to merge, or discard this patch.
back/src/KI/UserBundle/Security/SsoEnpcLoginAuthenticator.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,6 @@
 block discarded – undo
11 11
 use Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException;
12 12
 use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
13 13
 use Symfony\Component\Security\Core\User\UserInterface;
14
-
15 14
 use Symfony\Component\Security\Core\User\UserProviderInterface;
16 15
 
17 16
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
         $username = $credentials['username'];
71 71
 
72 72
         $email = $credentials['mail'];
73
-        if(!preg_match('/@eleves\.enpc\.fr$/', $email))
73
+        if (!preg_match('/@eleves\.enpc\.fr$/', $email))
74 74
             throw new AccessDeniedException();
75 75
 
76 76
         $user = null;
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
         }
83 83
 
84
-        if(!$user) {
84
+        if (!$user) {
85 85
             $user = $this->userRepository->findOneBy(['email' => $credentials['mail']]);
86 86
         }
87 87
 
Please login to merge, or discard this patch.