Passed
Push — master ( 0b1f4a...ec46a6 )
by Luiz Kim
02:24
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   +45 added lines, -29 removed lines patch added patch discarded remove patch
@@ -45,14 +45,17 @@  discard block
 block discarded – undo
45 45
   public function discoveryPeople(?string $document = null, ?string  $email = null, ?array $phone = [], ?string $name = null, ?string $peopleType = null): People
46 46
   {
47 47
 
48
-    if (!empty($document))
49
-      $people = $this->getDocument($document)?->getPeople();
48
+    if (!empty($document)) {
49
+          $people = $this->getDocument($document)?->getPeople();
50
+    }
50 51
 
51
-    if (!$people && !empty($email))
52
-      $people = $this->getEmail($email)?->getPeople();
52
+    if (!$people && !empty($email)) {
53
+          $people = $this->getEmail($email)?->getPeople();
54
+    }
53 55
 
54
-    if (!$people && !empty($phone))
55
-      $people = $this->getPhone($phone['ddd'], $phone['phone'])?->getPeople();
56
+    if (!$people && !empty($phone)) {
57
+          $people = $this->getPhone($phone['ddd'], $phone['phone'])?->getPeople();
58
+    }
56 59
 
57 60
     if (!$people) {
58 61
       $people = new People();
@@ -63,12 +66,15 @@  discard block
 block discarded – undo
63 66
       $this->manager->flush();
64 67
     }
65 68
 
66
-    if ($document)
67
-      $this->addDocument($people, $document);
68
-    if ($email)
69
-      $this->addEmail($people, $email);
70
-    if ($phone)
71
-      $this->addPhone($people, $phone);
69
+    if ($document) {
70
+          $this->addDocument($people, $document);
71
+    }
72
+    if ($email) {
73
+          $this->addEmail($people, $email);
74
+    }
75
+    if ($phone) {
76
+          $this->addPhone($people, $phone);
77
+    }
72 78
 
73 79
 
74 80
     return $people;
@@ -78,8 +84,9 @@  discard block
 block discarded – undo
78 84
   {
79 85
     $phone = $this->getPhone($phone_number['ddd'], $phone_number['phone']);
80 86
     if ($phone && $phone->getPeople()) {
81
-      if ($phone->getPeople()->getId() != $people->getId())
82
-        throw new Exception("Phone is in use by people " . $people->getId(), 1);
87
+      if ($phone->getPeople()->getId() != $people->getId()) {
88
+              throw new Exception("Phone is in use by people " . $people->getId(), 1);
89
+      }
83 90
     } else {
84 91
       $phone = new Phone();
85 92
       $phone->setDdd($phone_number['ddd']);
@@ -95,8 +102,9 @@  discard block
 block discarded – undo
95 102
   {
96 103
     $document = $this->getDocument($document_number, $document_type);
97 104
     if ($document) {
98
-      if ($document->getPeople()->getId() != $people->getId())
99
-        throw new Exception("Document is in use by people " . $people->getId(), 1);
105
+      if ($document->getPeople()->getId() != $people->getId()) {
106
+              throw new Exception("Document is in use by people " . $people->getId(), 1);
107
+      }
100 108
     } else {
101 109
       $document = new Document();
102 110
       $document->setDocument($document_number);
@@ -113,8 +121,9 @@  discard block
 block discarded – undo
113 121
   {
114 122
     $email = $this->getEmail($email_str);
115 123
     if ($email && $email->getPeople()) {
116
-      if ($email->getPeople()->getId() != $people->getId())
117
-        throw new Exception("Email is in use by people " . $people->getId(), 1);
124
+      if ($email->getPeople()->getId() != $people->getId()) {
125
+              throw new Exception("Email is in use by people " . $people->getId(), 1);
126
+      }
118 127
     } else {
119 128
       $email = new Email();
120 129
       $email->setEmail($email_str);
@@ -153,8 +162,9 @@  discard block
 block discarded – undo
153 162
 
154 163
   public function getDocument(string $document_number, ?string $document_type = null): ?Document
155 164
   {
156
-    if (!$document_type)
157
-      $document_type = $this->getDocumentTypeByDocumentLen($document_number);
165
+    if (!$document_type) {
166
+          $document_type = $this->getDocumentTypeByDocumentLen($document_number);
167
+    }
158 168
     return $this->manager->getRepository(Document::class)->findOneBy([
159 169
       'document' => $document_number,
160 170
       'documentType' =>
@@ -173,14 +183,15 @@  discard block
 block discarded – undo
173 183
     $payload   = json_decode($request->getContent());
174 184
     if (isset($payload->link_type)) {
175 185
       $company = $this->manager->getRepository(People::class)->find(preg_replace('/\D/', '', $payload->company));
176
-      if ($company)
177
-        $this->addLink($company, $people, $payload->link_type);
178
-      else {
186
+      if ($company) {
187
+              $this->addLink($company, $people, $payload->link_type);
188
+      } else {
179 189
         $link = $this->manager->getRepository(People::class)->find(preg_replace('/\D/', '', $payload->link));
180 190
         if ($payload->link_type == 'employee' && $link) {
181 191
           $this->addLink($people, $link, $payload->link_type);
182
-          if ($payload->people_document)
183
-            $this->addDocument($people, $payload->people_document);
192
+          if ($payload->people_document) {
193
+                      $this->addDocument($people, $payload->people_document);
194
+          }
184 195
         }
185 196
       }
186 197
     }
@@ -195,8 +206,9 @@  discard block
 block discarded – undo
195 206
       'link_type' => $link_type
196 207
     ]);
197 208
 
198
-    if (!$peopleLink)
199
-      $peopleLink = new PeopleLink();
209
+    if (!$peopleLink) {
210
+          $peopleLink = new PeopleLink();
211
+    }
200 212
 
201 213
     $peopleLink->setCompany($company);
202 214
     $peopleLink->setPeople($people);
@@ -248,10 +260,14 @@  discard block
 block discarded – undo
248 260
      * @var \ControleOnline\Entity\User $currentUser
249 261
      */
250 262
     $token = $this->security->getToken();
251
-    if (!$token) return [];
263
+    if (!$token) {
264
+     return [];
265
+    }
252 266
     $currentUser  =  $token->getUser();
253 267
     $companies    = [];
254
-    if (!$currentUser) return [];
268
+    if (!$currentUser) {
269
+     return [];
270
+    }
255 271
 
256 272
     if (!$currentUser->getPeople()->getLink()->isEmpty()) {
257 273
       foreach ($currentUser->getPeople()->getLink() as $company) {
Please login to merge, or discard this patch.