@@ -39,8 +39,9 @@ discard block |
||
| 39 | 39 | { |
| 40 | 40 | |
| 41 | 41 | $document = $this->manager->getRepository(Document::class)->findOneBy(['document' => $document_number]); |
| 42 | - if ($document) |
|
| 43 | - return $document->getPeople(); |
|
| 42 | + if ($document) { |
|
| 43 | + return $document->getPeople(); |
|
| 44 | + } |
|
| 44 | 45 | |
| 45 | 46 | |
| 46 | 47 | if ($name) { |
@@ -72,9 +73,9 @@ discard block |
||
| 72 | 73 | $payload = json_decode($request->getContent()); |
| 73 | 74 | if (isset($payload->link_type)) { |
| 74 | 75 | $company = $this->manager->getRepository(People::class)->find(preg_replace('/\D/', '', $payload->company)); |
| 75 | - if ($company) |
|
| 76 | - $this->addLink($company, $people, $payload->link_type); |
|
| 77 | - else { |
|
| 76 | + if ($company) { |
|
| 77 | + $this->addLink($company, $people, $payload->link_type); |
|
| 78 | + } else { |
|
| 78 | 79 | $link = $this->manager->getRepository(People::class)->find(preg_replace('/\D/', '', $payload->link)); |
| 79 | 80 | if ($payload->link_type == 'employee' && $link) { |
| 80 | 81 | $this->addLink($people, $link, $payload->link_type); |
@@ -102,8 +103,9 @@ discard block |
||
| 102 | 103 | 'link_type' => $link_type |
| 103 | 104 | ]); |
| 104 | 105 | |
| 105 | - if (!$peopleLink) |
|
| 106 | - $peopleLink = new PeopleLink(); |
|
| 106 | + if (!$peopleLink) { |
|
| 107 | + $peopleLink = new PeopleLink(); |
|
| 108 | + } |
|
| 107 | 109 | |
| 108 | 110 | $peopleLink->setCompany($company); |
| 109 | 111 | $peopleLink->setPeople($people); |
@@ -158,8 +160,9 @@ discard block |
||
| 158 | 160 | */ |
| 159 | 161 | $currentUser = $this->security->getToken()->getUser(); |
| 160 | 162 | $companies = []; |
| 161 | - if (!$currentUser) |
|
| 162 | - return []; |
|
| 163 | + if (!$currentUser) { |
|
| 164 | + return []; |
|
| 165 | + } |
|
| 163 | 166 | |
| 164 | 167 | if (!$currentUser->getPeople()->getLink()->isEmpty()) { |
| 165 | 168 | foreach ($currentUser->getPeople()->getLink() as $company) { |
@@ -27,13 +27,13 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @var Request |
| 29 | 29 | */ |
| 30 | - private $request = null; |
|
| 30 | + private $request = null; |
|
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | public function __construct(EntityManagerInterface $manager) |
| 35 | 35 | { |
| 36 | - $this->manager = $manager; |
|
| 36 | + $this->manager = $manager; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | public function __invoke(People $data, Request $request): JsonResponse |
@@ -75,12 +75,12 @@ discard block |
||
| 75 | 75 | throw new \InvalidArgumentException('Document id is not defined'); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - $users = $this->manager->getRepository(User::class)->findBy(['people' => $person]); |
|
| 78 | + $users = $this->manager->getRepository(User::class)->findBy(['people' => $person]); |
|
| 79 | 79 | if (count($users) == 1) { |
| 80 | 80 | throw new \InvalidArgumentException('Deve existir pelo menos um usuário'); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - $user = $this->manager->getRepository(User::class)->findOneBy(['id' => $payload['id'], 'people' => $person]); |
|
| 83 | + $user = $this->manager->getRepository(User::class)->findOneBy(['id' => $payload['id'], 'people' => $person]); |
|
| 84 | 84 | if (!$user instanceof User) { |
| 85 | 85 | throw new \InvalidArgumentException('Person user was not found'); |
| 86 | 86 | } |