Passed
Push — master ( b73a64...9b2d66 )
by Luiz Kim
02:21
created
src/Service/TaskInterationService.php 3 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -12,42 +12,42 @@  discard block
 block discarded – undo
12 12
 class TaskInterationService
13 13
 {
14 14
 
15
-  public function __construct(
15
+    public function __construct(
16 16
     private EntityManagerInterface $manager,
17 17
     private Security $security,
18 18
     private StatusService $statusService,
19 19
     private PeopleService $peopleService,
20 20
     private FileService $fileService,
21 21
     private IntegrationService $integrationService
22
-  ) {}
22
+    ) {}
23 23
 
24
-  public function addClientInteration(MessageInterface $message, People $provider, string $type): TaskInteration
25
-  {
24
+    public function addClientInteration(MessageInterface $message, People $provider, string $type): TaskInteration
25
+    {
26 26
 
27 27
     $number = preg_replace('/\D/', '', $message->getOriginNumber());
28 28
     $name = '';
29 29
     $phone = [
30
-      'ddi' => substr($number, 0, 2),
31
-      'ddd' => substr($number, 2, 2),
32
-      'phone' => substr($number, 4)
30
+        'ddi' => substr($number, 0, 2),
31
+        'ddd' => substr($number, 2, 2),
32
+        'phone' => substr($number, 4)
33 33
     ];
34 34
     $registredBy = $this->peopleService->discoveryPeople(null,  null,  $phone,  $name, null);
35 35
     $task = $this->discoveryOpenTask($provider, $registredBy, $type, $number);
36 36
 
37 37
     return $this->addInteration($registredBy, $message, $task, $type, 'public');
38
-  }
38
+    }
39 39
 
40
-  public function addInteration(People $registredBy, MessageInterface $message, Task $task, string $type, ?string $visibility = 'private')
41
-  {
40
+    public function addInteration(People $registredBy, MessageInterface $message, Task $task, string $type, ?string $visibility = 'private')
41
+    {
42 42
 
43 43
     $file = null;
44 44
     $media = $message->getMessageContent()->getMedia();
45 45
     if ($media)
46
-      $file = $this->fileService->addFile(
46
+        $file = $this->fileService->addFile(
47 47
         $registredBy,
48 48
         pack("C*", ...$media->getData()),
49 49
         $type
50
-      );
50
+        );
51 51
 
52 52
     $taskInteration = new TaskInteration();
53 53
     $taskInteration->setTask($task);
@@ -56,32 +56,32 @@  discard block
 block discarded – undo
56 56
     $taskInteration->setBody($message->getMessageContent()->getBody());
57 57
     $taskInteration->setRegisteredBy($registredBy);
58 58
     if ($file)
59
-      $taskInteration->setFile($file);
59
+        $taskInteration->setFile($file);
60 60
 
61 61
     $this->manager->persist($taskInteration);
62 62
     $this->manager->flush();
63 63
 
64 64
     return $taskInteration;
65
-  }
65
+    }
66 66
 
67
-  public function discoveryOpenTask(People $provider, People $registredBy, string $type, ?string $announce = null): Task
68
-  {
67
+    public function discoveryOpenTask(People $provider, People $registredBy, string $type, ?string $announce = null): Task
68
+    {
69 69
 
70 70
     $openStatus = $this->statusService->discoveryStatus('open', 'open', $type);
71 71
     $pendingStatus = $this->statusService->discoveryStatus('pending', 'pending', $type);
72 72
 
73 73
     $task = $this->manager->getRepository(Task::class)->findOneBy([
74
-      'taskStatus' => [$openStatus, $pendingStatus],
75
-      'provider' => $provider,
76
-      'registeredBy' => $registredBy,
77
-      'type' => $type
74
+        'taskStatus' => [$openStatus, $pendingStatus],
75
+        'provider' => $provider,
76
+        'registeredBy' => $registredBy,
77
+        'type' => $type
78 78
     ]);
79 79
 
80 80
     if (!$task) {
81
-      $task = new Task();
82
-      $task->setRegisteredBy($registredBy);
83
-      $task->setProvider($provider);
84
-      $task->settype($type);
81
+        $task = new Task();
82
+        $task->setRegisteredBy($registredBy);
83
+        $task->setProvider($provider);
84
+        $task->settype($type);
85 85
     }
86 86
 
87 87
     if ($announce) $task->addAnnounce($announce);
@@ -90,39 +90,39 @@  discard block
 block discarded – undo
90 90
     $this->manager->flush();
91 91
 
92 92
     return $task;
93
-  }
93
+    }
94 94
 
95
-  public function notifyClient(TaskInteration $taskInteration): TaskInteration
96
-  {
95
+    public function notifyClient(TaskInteration $taskInteration): TaskInteration
96
+    {
97 97
 
98 98
     $task = $taskInteration->getTask();
99 99
     $origin = "551131360353";
100 100
 
101 101
     foreach ($task->getAnnounce(true) as $destination) {
102
-      if ($origin != $destination) {
102
+        if ($origin != $destination) {
103 103
         $message = json_encode([
104
-          "action" => "sendMessage",
105
-          "origin" => $origin,
106
-          "destination" => $destination,
107
-          "message" => json_encode($taskInteration->getBody()),
108
-          //"file" => $taskInteration->getFile()
104
+            "action" => "sendMessage",
105
+            "origin" => $origin,
106
+            "destination" => $destination,
107
+            "message" => json_encode($taskInteration->getBody()),
108
+            //"file" => $taskInteration->getFile()
109 109
         ]);
110 110
         $this->integrationService->addIntegration($message, 'WhatsApp', null, null, $task->getProvider());
111
-      }
111
+        }
112 112
     }
113 113
 
114 114
     return  $taskInteration;
115
-  }
115
+    }
116 116
 
117
-  public function prePersist(TaskInteration $taskInteration): TaskInteration
118
-  {
117
+    public function prePersist(TaskInteration $taskInteration): TaskInteration
118
+    {
119 119
     if (!$taskInteration->getRegisteredBy())
120
-      $taskInteration->setRegisteredBy($this->security->getToken()->getUser()->getPeople());
120
+        $taskInteration->setRegisteredBy($this->security->getToken()->getUser()->getPeople());
121 121
     return  $taskInteration;
122
-  }
122
+    }
123 123
 
124
-  public function posPersist(TaskInteration $taskInteration): TaskInteration
125
-  {
124
+    public function posPersist(TaskInteration $taskInteration): TaskInteration
125
+    {
126 126
     return $this->notifyClient($taskInteration);
127
-  }
127
+    }
128 128
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
       'ddd' => substr($number, 2, 2),
32 32
       'phone' => substr($number, 4)
33 33
     ];
34
-    $registredBy = $this->peopleService->discoveryPeople(null,  null,  $phone,  $name, null);
34
+    $registredBy = $this->peopleService->discoveryPeople(null, null, $phone, $name, null);
35 35
     $task = $this->discoveryOpenTask($provider, $registredBy, $type, $number);
36 36
 
37 37
     return $this->addInteration($registredBy, $message, $task, $type, 'public');
Please login to merge, or discard this patch.
Braces   +12 added lines, -7 removed lines patch added patch discarded remove patch
@@ -42,12 +42,13 @@  discard block
 block discarded – undo
42 42
 
43 43
     $file = null;
44 44
     $media = $message->getMessageContent()->getMedia();
45
-    if ($media)
46
-      $file = $this->fileService->addFile(
45
+    if ($media) {
46
+          $file = $this->fileService->addFile(
47 47
         $registredBy,
48 48
         pack("C*", ...$media->getData()),
49 49
         $type
50 50
       );
51
+    }
51 52
 
52 53
     $taskInteration = new TaskInteration();
53 54
     $taskInteration->setTask($task);
@@ -55,8 +56,9 @@  discard block
 block discarded – undo
55 56
     $taskInteration->setVisibility($visibility);
56 57
     $taskInteration->setBody($message->getMessageContent()->getBody());
57 58
     $taskInteration->setRegisteredBy($registredBy);
58
-    if ($file)
59
-      $taskInteration->setFile($file);
59
+    if ($file) {
60
+          $taskInteration->setFile($file);
61
+    }
60 62
 
61 63
     $this->manager->persist($taskInteration);
62 64
     $this->manager->flush();
@@ -84,7 +86,9 @@  discard block
 block discarded – undo
84 86
       $task->settype($type);
85 87
     }
86 88
 
87
-    if ($announce) $task->addAnnounce($announce);
89
+    if ($announce) {
90
+        $task->addAnnounce($announce);
91
+    }
88 92
     $task->setTaskStatus($openStatus);
89 93
     $this->manager->persist($task);
90 94
     $this->manager->flush();
@@ -116,8 +120,9 @@  discard block
 block discarded – undo
116 120
 
117 121
   public function prePersist(TaskInteration $taskInteration): TaskInteration
118 122
   {
119
-    if (!$taskInteration->getRegisteredBy())
120
-      $taskInteration->setRegisteredBy($this->security->getToken()->getUser()->getPeople());
123
+    if (!$taskInteration->getRegisteredBy()) {
124
+          $taskInteration->setRegisteredBy($this->security->getToken()->getUser()->getPeople());
125
+    }
121 126
     return  $taskInteration;
122 127
   }
123 128
 
Please login to merge, or discard this patch.
src/Entity/Task.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
     {
291 291
         return $this->alterDate;
292 292
     }
293
-    public function getAnnounce(bool $decode = false): string|array
293
+    public function getAnnounce(bool $decode = false): string | array
294 294
     {
295 295
         // Ensure we're decoding a string, even if it was temporarily an array internally
296 296
         $announceString = is_array($this->announce) ? json_encode($this->announce) : $this->announce;
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
         return $this->setAnnounce($announce);
308 308
     }
309 309
 
310
-    public function setAnnounce(string|array|object $announce): self
310
+    public function setAnnounce(string | array | object $announce): self
311 311
     {
312 312
         if (is_string($announce))
313 313
             $announce = json_decode($announce, true);
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -301,16 +301,18 @@
 block discarded – undo
301 301
     {
302 302
         $announce = $this->getAnnounce(true);
303 303
         
304
-        if (!in_array($value, $announce))
305
-            array_push($announce, $value);
304
+        if (!in_array($value, $announce)) {
305
+                    array_push($announce, $value);
306
+        }
306 307
 
307 308
         return $this->setAnnounce($announce);
308 309
     }
309 310
 
310 311
     public function setAnnounce(string|array|object $announce): self
311 312
     {
312
-        if (is_string($announce))
313
-            $announce = json_decode($announce, true);
313
+        if (is_string($announce)) {
314
+                    $announce = json_decode($announce, true);
315
+        }
314 316
 
315 317
         $this->announce = json_encode($announce);
316 318
         return $this;
Please login to merge, or discard this patch.