Passed
Push — master ( cfd6ca...e64e6c )
by Luiz Kim
02:23
created
src/Controller/DeleteUserAction.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -113,8 +113,9 @@
 block discarded – undo
113 113
 
114 114
             return true;
115 115
         } catch (\Exception $e) {
116
-            if ($this->manager->getConnection()->isTransactionActive())
117
-                $this->manager->getConnection()->rollBack();
116
+            if ($this->manager->getConnection()->isTransactionActive()) {
117
+                            $this->manager->getConnection()->rollBack();
118
+            }
118 119
 
119 120
             throw new \InvalidArgumentException($e->getMessage());
120 121
         }
Please login to merge, or discard this patch.
src/Repository/PeopleRepository.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,8 +51,9 @@
 block discarded – undo
51 51
             ->setParameter('company', $company->getId())
52 52
             ->setParameter('people', $people->getId());
53 53
 
54
-        if ($linkType)
55
-            $queryBuilder->setParameter('linkType', $linkType)->andWhere('pl.link_type = :linkType');
54
+        if ($linkType) {
55
+                    $queryBuilder->setParameter('linkType', $linkType)->andWhere('pl.link_type = :linkType');
56
+        }
56 57
 
57 58
         if ($maxResults) {
58 59
             $queryBuilder->setMaxResults($maxResults);
Please login to merge, or discard this patch.
src/Service/PeopleRoleService.php 1 patch
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -34,7 +34,9 @@  discard block
 block discarded – undo
34 34
     $isSalesman = false;
35 35
 
36 36
     $isSalesman = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $people, 'salesman', 1);
37
-    if ($isSalesman) return true;
37
+    if ($isSalesman) {
38
+     return true;
39
+    }
38 40
 
39 41
     $getPeopleCompanies = $this->manager->getRepository(PeopleLink::class)->findBy([
40 42
       'people' => $people,
@@ -45,7 +47,9 @@  discard block
 block discarded – undo
45 47
      */
46 48
     foreach ($getPeopleCompanies as $peopleCompany) {
47 49
       $isSalesman = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $peopleCompany->getCompany(), 'salesman', 1);
48
-      if ($isSalesman) return true;
50
+      if ($isSalesman) {
51
+       return true;
52
+      }
49 53
     }
50 54
     return $isSalesman;
51 55
   }
@@ -57,8 +61,9 @@  discard block
 block discarded – undo
57 61
     $mainCompany = $this->getMainCompany();
58 62
 
59 63
     $isSuper = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $people, 'employee', 1);
60
-    if ($isSuper)
61
-      $peopleRole[] = 'super';
64
+    if ($isSuper) {
65
+          $peopleRole[] = 'super';
66
+    }
62 67
 
63 68
 
64 69
 
@@ -69,13 +74,15 @@  discard block
 block discarded – undo
69 74
     }
70 75
 
71 76
     $isClient = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $people, 'client', 1);
72
-    if ($isClient)
73
-      $peopleRole[] = 'client';
77
+    if ($isClient) {
78
+          $peopleRole[] = 'client';
79
+    }
74 80
 
75 81
 
76 82
     $isSalesman = $this->isSalesman($people);
77
-    if ($isSalesman)
78
-      $peopleRole[] = 'salesman';
83
+    if ($isSalesman) {
84
+          $peopleRole[] = 'salesman';
85
+    }
79 86
 
80 87
 
81 88
     return array_values(array_unique(empty($peopleRole) ? ['guest'] : $peopleRole));
@@ -89,7 +96,9 @@  discard block
 block discarded – undo
89 96
   public function getMainCompany(): People
90 97
   {
91 98
 
92
-    if (self::$mainCompany) return self::$mainCompany;
99
+    if (self::$mainCompany) {
100
+     return self::$mainCompany;
101
+    }
93 102
 
94 103
     $peopleDomain = $this->domainService->getPeopleDomain();
95 104
     self::$mainCompany =  $peopleDomain->getPeople();
Please login to merge, or discard this patch.
src/Service/PeopleService.php 1 patch
Braces   +42 added lines, -27 removed lines patch added patch discarded remove patch
@@ -47,11 +47,13 @@  discard block
 block discarded – undo
47 47
 
48 48
     $people = $this->getDocument($document)?->getPeople();
49 49
 
50
-    if (!$people)
51
-      $people = $this->getEmail($email)?->getPeople();
50
+    if (!$people) {
51
+          $people = $this->getEmail($email)?->getPeople();
52
+    }
52 53
 
53
-    if (!$people)
54
-      $people = $this->getPhone($phone['ddd'], $phone['phone'])?->getPeople();
54
+    if (!$people) {
55
+          $people = $this->getPhone($phone['ddd'], $phone['phone'])?->getPeople();
56
+    }
55 57
 
56 58
     if (!$people) {
57 59
       $people = new People();
@@ -62,12 +64,15 @@  discard block
 block discarded – undo
62 64
       $this->manager->flush();
63 65
     }
64 66
 
65
-    if ($document)
66
-      $this->addDocument($people, $document);
67
-    if ($email)
68
-      $this->addEmail($people, $email);
69
-    if ($phone)
70
-      $this->addPhone($people, $phone);
67
+    if ($document) {
68
+          $this->addDocument($people, $document);
69
+    }
70
+    if ($email) {
71
+          $this->addEmail($people, $email);
72
+    }
73
+    if ($phone) {
74
+          $this->addPhone($people, $phone);
75
+    }
71 76
 
72 77
 
73 78
     return $people;
@@ -77,8 +82,9 @@  discard block
 block discarded – undo
77 82
   {
78 83
     $phone = $this->getPhone($phone_number['ddd'], $phone_number['phone']);
79 84
     if ($phone && $phone->getPeople()) {
80
-      if ($phone->getPeople()->getId() != $people->getId())
81
-        throw new Exception("Phone is in use by people " . $people->getId(), 1);
85
+      if ($phone->getPeople()->getId() != $people->getId()) {
86
+              throw new Exception("Phone is in use by people " . $people->getId(), 1);
87
+      }
82 88
     } else {
83 89
       $phone = new Phone();
84 90
       $phone->setDdd($phone_number['ddd']);
@@ -94,8 +100,9 @@  discard block
 block discarded – undo
94 100
   {
95 101
     $document = $this->getDocument($document_number, $document_type);
96 102
     if ($document) {
97
-      if ($document->getPeople()->getId() != $people->getId())
98
-        throw new Exception("Document is in use by people " . $people->getId(), 1);
103
+      if ($document->getPeople()->getId() != $people->getId()) {
104
+              throw new Exception("Document is in use by people " . $people->getId(), 1);
105
+      }
99 106
     } else {
100 107
       $document = new Document();
101 108
       $document->setDocument($document_number);
@@ -112,8 +119,9 @@  discard block
 block discarded – undo
112 119
   {
113 120
     $email = $this->getEmail($email_str);
114 121
     if ($email && $email->getPeople()) {
115
-      if ($email->getPeople()->getId() != $people->getId())
116
-        throw new Exception("Email is in use by people " . $people->getId(), 1);
122
+      if ($email->getPeople()->getId() != $people->getId()) {
123
+              throw new Exception("Email is in use by people " . $people->getId(), 1);
124
+      }
117 125
     } else {
118 126
       $email = new Email();
119 127
       $email->setEmail($email_str);
@@ -152,8 +160,9 @@  discard block
 block discarded – undo
152 160
 
153 161
   public function getDocument(string $document_number, ?string $document_type = null): ?Document
154 162
   {
155
-    if (!$document_type)
156
-      $document_type = $this->getDocumentTypeByDocumentLen($document_number);
163
+    if (!$document_type) {
164
+          $document_type = $this->getDocumentTypeByDocumentLen($document_number);
165
+    }
157 166
     return $this->manager->getRepository(Document::class)->findOneBy([
158 167
       'document' => $document_number,
159 168
       'documentType' =>
@@ -172,14 +181,15 @@  discard block
 block discarded – undo
172 181
     $payload   = json_decode($request->getContent());
173 182
     if (isset($payload->link_type)) {
174 183
       $company = $this->manager->getRepository(People::class)->find(preg_replace('/\D/', '', $payload->company));
175
-      if ($company)
176
-        $this->addLink($company, $people, $payload->link_type);
177
-      else {
184
+      if ($company) {
185
+              $this->addLink($company, $people, $payload->link_type);
186
+      } else {
178 187
         $link = $this->manager->getRepository(People::class)->find(preg_replace('/\D/', '', $payload->link));
179 188
         if ($payload->link_type == 'employee' && $link) {
180 189
           $this->addLink($people, $link, $payload->link_type);
181
-          if ($payload->people_document)
182
-            $this->addDocument($people, $payload->people_document);
190
+          if ($payload->people_document) {
191
+                      $this->addDocument($people, $payload->people_document);
192
+          }
183 193
         }
184 194
       }
185 195
     }
@@ -194,8 +204,9 @@  discard block
 block discarded – undo
194 204
       'link_type' => $link_type
195 205
     ]);
196 206
 
197
-    if (!$peopleLink)
198
-      $peopleLink = new PeopleLink();
207
+    if (!$peopleLink) {
208
+          $peopleLink = new PeopleLink();
209
+    }
199 210
 
200 211
     $peopleLink->setCompany($company);
201 212
     $peopleLink->setPeople($people);
@@ -247,10 +258,14 @@  discard block
 block discarded – undo
247 258
      * @var \ControleOnline\Entity\User $currentUser
248 259
      */
249 260
     $token = $this->security->getToken();
250
-    if (!$token) return [];
261
+    if (!$token) {
262
+     return [];
263
+    }
251 264
     $currentUser  =  $token->getUser();
252 265
     $companies    = [];
253
-    if (!$currentUser) return [];
266
+    if (!$currentUser) {
267
+     return [];
268
+    }
254 269
 
255 270
     if (!$currentUser->getPeople()->getLink()->isEmpty()) {
256 271
       foreach ($currentUser->getPeople()->getLink() as $company) {
Please login to merge, or discard this patch.