Passed
Push — master ( 02f370...d35b2f )
by Luiz Kim
02:15
created
src/Service/TaskInterationService.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -12,45 +12,45 @@  discard block
 block discarded – undo
12 12
 class TaskInterationService
13 13
 {
14 14
 
15
-  private bool $notify = true;
15
+    private bool $notify = true;
16 16
 
17
-  public function __construct(
17
+    public function __construct(
18 18
     private EntityManagerInterface $manager,
19 19
     private Security $security,
20 20
     private StatusService $statusService,
21 21
     private PeopleService $peopleService,
22 22
     private FileService $fileService,
23 23
     private IntegrationService $integrationService
24
-  ) {}
24
+    ) {}
25 25
 
26
-  public function addClientInteration(MessageInterface $message, People $provider, string $type): TaskInteration
27
-  {
26
+    public function addClientInteration(MessageInterface $message, People $provider, string $type): TaskInteration
27
+    {
28 28
 
29 29
     $this->notify = false;
30 30
     $number = preg_replace('/\D/', '', $message->getOriginNumber());
31 31
     $name = '';
32 32
     $phone = [
33
-      'ddi' => substr($number, 0, 2),
34
-      'ddd' => substr($number, 2, 2),
35
-      'phone' => substr($number, 4)
33
+        'ddi' => substr($number, 0, 2),
34
+        'ddd' => substr($number, 2, 2),
35
+        'phone' => substr($number, 4)
36 36
     ];
37 37
     $registredBy = $this->peopleService->discoveryPeople(null,  null,  $phone,  $name, null);
38 38
     $task = $this->discoveryOpenTask($provider, $registredBy, $type, $number);
39 39
 
40 40
     return $this->addInteration($registredBy, $message, $task, $type, 'public');
41
-  }
41
+    }
42 42
 
43
-  public function addInteration(People $registredBy, MessageInterface $message, Task $task, string $type, ?string $visibility = 'private')
44
-  {
43
+    public function addInteration(People $registredBy, MessageInterface $message, Task $task, string $type, ?string $visibility = 'private')
44
+    {
45 45
 
46 46
     $file = null;
47 47
     $media = $message->getMessageContent()->getMedia();
48 48
     if ($media)
49
-      $file = $this->fileService->addFile(
49
+        $file = $this->fileService->addFile(
50 50
         $registredBy,
51 51
         pack("C*", ...$media->getData()),
52 52
         $type
53
-      );
53
+        );
54 54
 
55 55
     $taskInteration = new TaskInteration();
56 56
     $taskInteration->setTask($task);
@@ -59,32 +59,32 @@  discard block
 block discarded – undo
59 59
     $taskInteration->setBody($message->getMessageContent()->getBody());
60 60
     $taskInteration->setRegisteredBy($registredBy);
61 61
     if ($file)
62
-      $taskInteration->setFile($file);
62
+        $taskInteration->setFile($file);
63 63
 
64 64
     $this->manager->persist($taskInteration);
65 65
     $this->manager->flush();
66 66
 
67 67
     return $taskInteration;
68
-  }
68
+    }
69 69
 
70
-  public function discoveryOpenTask(People $provider, People $registredBy, string $type, ?string $announce = null): Task
71
-  {
70
+    public function discoveryOpenTask(People $provider, People $registredBy, string $type, ?string $announce = null): Task
71
+    {
72 72
 
73 73
     $openStatus = $this->statusService->discoveryStatus('open', 'open', $type);
74 74
     $pendingStatus = $this->statusService->discoveryStatus('pending', 'pending', $type);
75 75
 
76 76
     $task = $this->manager->getRepository(Task::class)->findOneBy([
77
-      'taskStatus' => [$openStatus, $pendingStatus],
78
-      'provider' => $provider,
79
-      'registeredBy' => $registredBy,
80
-      'type' => $type
77
+        'taskStatus' => [$openStatus, $pendingStatus],
78
+        'provider' => $provider,
79
+        'registeredBy' => $registredBy,
80
+        'type' => $type
81 81
     ]);
82 82
 
83 83
     if (!$task) {
84
-      $task = new Task();
85
-      $task->setRegisteredBy($registredBy);
86
-      $task->setProvider($provider);
87
-      $task->settype($type);
84
+        $task = new Task();
85
+        $task->setRegisteredBy($registredBy);
86
+        $task->setProvider($provider);
87
+        $task->settype($type);
88 88
     }
89 89
 
90 90
     if ($announce) $task->addAnnounce($announce);
@@ -93,39 +93,39 @@  discard block
 block discarded – undo
93 93
     $this->manager->flush();
94 94
 
95 95
     return $task;
96
-  }
96
+    }
97 97
 
98
-  public function notifyClient(TaskInteration $taskInteration): TaskInteration
99
-  {
98
+    public function notifyClient(TaskInteration $taskInteration): TaskInteration
99
+    {
100 100
     if (!$this->notify) return $taskInteration;
101 101
     $task = $taskInteration->getTask();
102 102
     $origin = "551131360353";
103 103
 
104 104
     foreach ($task->getAnnounce(true) as $destination) {
105
-      if ($origin != $destination) {
105
+        if ($origin != $destination) {
106 106
         $message = json_encode([
107
-          "action" => "sendMessage",
108
-          "origin" => $origin,
109
-          "destination" => $destination,
110
-          "message" => $taskInteration->getBody(),
111
-          //"file" => $taskInteration->getFile()
107
+            "action" => "sendMessage",
108
+            "origin" => $origin,
109
+            "destination" => $destination,
110
+            "message" => $taskInteration->getBody(),
111
+            //"file" => $taskInteration->getFile()
112 112
         ]);
113 113
         $this->integrationService->addIntegration($message, 'WhatsApp', null, null, $task->getProvider());
114
-      }
114
+        }
115 115
     }
116 116
 
117 117
     return  $taskInteration;
118
-  }
118
+    }
119 119
 
120
-  public function prePersist(TaskInteration $taskInteration): TaskInteration
121
-  {
120
+    public function prePersist(TaskInteration $taskInteration): TaskInteration
121
+    {
122 122
     if (!$taskInteration->getRegisteredBy())
123
-      $taskInteration->setRegisteredBy($this->security->getToken()->getUser()->getPeople());
123
+        $taskInteration->setRegisteredBy($this->security->getToken()->getUser()->getPeople());
124 124
     return  $taskInteration;
125
-  }
125
+    }
126 126
 
127
-  public function postPersist(TaskInteration $taskInteration): TaskInteration
128
-  {
127
+    public function postPersist(TaskInteration $taskInteration): TaskInteration
128
+    {
129 129
     return $this->notifyClient($taskInteration);
130
-  }
130
+    }
131 131
 }
Please login to merge, or discard this patch.