Passed
Push — master ( 3fc116...b4cdc7 )
by Luiz Kim
02:39
created
src/Service/PeopleService.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     private Security               $security,
28 28
     private RequestStack $requestStack,
29 29
   ) {
30
-    $this->request  = $requestStack->getCurrentRequest();
30
+    $this->request = $requestStack->getCurrentRequest();
31 31
   }
32 32
 
33 33
   public function prePersist(People $people)
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     $phone = $this->getPhone($phone_number['ddd'], $phone_number['phone']);
80 80
     if ($phone && $phone->getPeople()) {
81 81
       if ($phone->getPeople()->getId() != $people->getId())
82
-        throw new Exception("Phone is in use by people " . $people->getId(), 1);
82
+        throw new Exception("Phone is in use by people ".$people->getId(), 1);
83 83
     } else {
84 84
       $phone = new Phone();
85 85
       $phone->setDdd((int) $phone_number['ddd']);
@@ -91,16 +91,16 @@  discard block
 block discarded – undo
91 91
 
92 92
     return  $phone;
93 93
   }
94
-  public function addDocument(People $people, string|int $document_number, ?string $document_type = null): Document
94
+  public function addDocument(People $people, string | int $document_number, ?string $document_type = null): Document
95 95
   {
96 96
     $document = $this->getDocument($document_number, $document_type);
97 97
     if ($document) {
98 98
       if ($document->getPeople()->getId() != $people->getId())
99
-        throw new Exception("Document is in use by people " . $people->getId(), 1);
99
+        throw new Exception("Document is in use by people ".$people->getId(), 1);
100 100
     } else {
101 101
       $document_type = $document_type ? $this->discoveryDocumentType($document_type) : $this->discoveryDocumentType($this->getDocumentTypeByDocumentLen($document_number));
102 102
       $document = new Document();
103
-      $document->setDocument((int)$document_number);
103
+      $document->setDocument((int) $document_number);
104 104
       $document->setDocumentType($document_type);
105 105
       $document->setPeople($people);
106 106
       $this->manager->persist($document);
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     $email = $this->getEmail($email_str);
116 116
     if ($email && $email->getPeople()) {
117 117
       if ($email->getPeople()->getId() != $people->getId())
118
-        throw new Exception("Email is in use by people " . $people->getId(), 1);
118
+        throw new Exception("Email is in use by people ".$people->getId(), 1);
119 119
     } else {
120 120
       $email = new Email();
121 121
       $email->setEmail($email_str);
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
   public function discoveryDocumentType(string $document_type): DocumentType
142 142
   {
143
-    $documentType =  $this->manager->getRepository(DocumentType::class)->findOneBy(['documentType' => $document_type]);
143
+    $documentType = $this->manager->getRepository(DocumentType::class)->findOneBy(['documentType' => $document_type]);
144 144
 
145 145
     if (!$documentType) {
146 146
       $documentType = new DocumentType();
@@ -222,29 +222,29 @@  discard block
 block discarded – undo
222 222
   public function checkLink(QueryBuilder $queryBuilder, $resourceClass = null, $applyTo = null, $rootAlias = null): void
223 223
   {
224 224
 
225
-    $link   = $this->request->query->get('link',   null);
225
+    $link = $this->request->query->get('link', null);
226 226
     $company = $this->request->query->get('company', null);
227 227
     $link_type = $this->request->query->get('link_type', null);
228 228
 
229 229
     if ($link_type) {
230
-      $queryBuilder->join(sprintf('%s.' . ($link ? 'company' : 'link'), $rootAlias), 'PeopleLink');
230
+      $queryBuilder->join(sprintf('%s.'.($link ? 'company' : 'link'), $rootAlias), 'PeopleLink');
231 231
       $queryBuilder->andWhere('PeopleLink.link_type IN(:link_type)');
232 232
       $queryBuilder->setParameter('link_type', $link_type);
233 233
     }
234 234
 
235 235
     if ($company || $link) {
236
-      $queryBuilder->andWhere('PeopleLink.' . ($link ? 'people' : 'company') . ' IN(:people)');
236
+      $queryBuilder->andWhere('PeopleLink.'.($link ? 'people' : 'company').' IN(:people)');
237 237
       $queryBuilder->setParameter('people', preg_replace("/[^0-9]/", "", ($link ?: $company)));
238 238
     }
239 239
   }
240 240
   public function checkCompany($type, QueryBuilder $queryBuilder, $resourceClass = null, $applyTo = null, $rootAlias = null): void
241 241
   {
242
-    $companies   = $this->getMyCompanies();
243
-    $queryBuilder->andWhere(sprintf('%s.' . $type . ' IN(:companies)', $rootAlias, $rootAlias));
242
+    $companies = $this->getMyCompanies();
243
+    $queryBuilder->andWhere(sprintf('%s.'.$type.' IN(:companies)', $rootAlias, $rootAlias));
244 244
     $queryBuilder->setParameter('companies', $companies);
245 245
 
246 246
     if ($payer = $this->request->query->get('company', null)) {
247
-      $queryBuilder->andWhere(sprintf('%s.' . $type . ' IN(:people)', $rootAlias));
247
+      $queryBuilder->andWhere(sprintf('%s.'.$type.' IN(:people)', $rootAlias));
248 248
       $queryBuilder->setParameter('people', preg_replace("/[^0-9]/", "", $payer));
249 249
     }
250 250
   }
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
      */
257 257
     $token = $this->security->getToken();
258 258
     if (!$token) return [];
259
-    $currentUser  =  $token->getUser();
259
+    $currentUser  = $token->getUser();
260 260
     $companies    = [];
261 261
     if (!$currentUser) return [];
262 262
 
Please login to merge, or discard this patch.