Passed
Push — master ( 48efbe...67f36e )
by Luiz Kim
02:44
created
src/Service/SignatureService.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -13,25 +13,25 @@  discard block
 block discarded – undo
13 13
 class SignatureService
14 14
 {
15 15
 
16
-  public function __construct(
16
+    public function __construct(
17 17
     private EntityManagerInterface $manager,
18 18
     private PeopleRoleService $peopleRoleService,
19 19
     private SignatureContract $signatureContract,
20 20
     private PdfService $pdf,
21 21
     private ModelService $modelService
22
-  ) {}
22
+    ) {}
23 23
 
24 24
 
25
-  public function sign(Contract $data)
26
-  {
25
+    public function sign(Contract $data)
26
+    {
27 27
     return $this->signatureContract->sign($data);
28
-  }
28
+    }
29 29
 
30
-  public function genetateFromModel(Contract $data)
31
-  {
30
+    public function genetateFromModel(Contract $data)
31
+    {
32 32
     $file = $data->getContractFile();
33 33
     if (!$file)
34
-      $file = new File();
34
+        $file = new File();
35 35
 
36 36
     $file->setFileType('text');
37 37
     $file->setExtension('html');
@@ -40,83 +40,83 @@  discard block
 block discarded – undo
40 40
     $this->manager->flush();
41 41
 
42 42
     return $data;
43
-  }
43
+    }
44 44
 
45 45
 
46
-  public function getContractPDFContent(Contract $contract): string
47
-  {
46
+    public function getContractPDFContent(Contract $contract): string
47
+    {
48 48
     $content = $contract->getContractFile()->getContent();
49 49
 
50 50
     if ($contract->getContractFile()->getExtension() == 'pdf')
51
-      return $content;
51
+        return $content;
52 52
 
53 53
     if (empty($content)) {
54
-      throw new \Exception(
54
+        throw new \Exception(
55 55
         sprintf('Houve um erro ao gerar o PDF')
56
-      );
56
+        );
57 57
     }
58 58
 
59 59
     return $this->pdf->convertHtmlToPdf($content);
60
-  }
60
+    }
61 61
 
62
-  public function getFactory(?string $factoryName = null): ?SignatureFactory
63
-  {
62
+    public function getFactory(?string $factoryName = null): ?SignatureFactory
63
+    {
64 64
     $providerName = $factoryName === null ?
65 65
       $this->getDefaultProviderFromConfig() : $factoryName;
66 66
 
67 67
     if ($providerName === null) {
68
-      return null;
68
+        return null;
69 69
     }
70 70
 
71 71
     $provider = sprintf(
72
-      '\\App\\Library\\Provider\\Signature\\%s\\Factory',
73
-      ucfirst(strtolower($providerName))
72
+        '\\App\\Library\\Provider\\Signature\\%s\\Factory',
73
+        ucfirst(strtolower($providerName))
74 74
     );
75 75
 
76 76
     if (!class_exists($provider)) {
77
-      throw new \Exception('Signature provider factory not found');
77
+        throw new \Exception('Signature provider factory not found');
78 78
     }
79 79
 
80 80
     return new $provider(
81
-      $this->getProviderConfig($providerName)
81
+        $this->getProviderConfig($providerName)
82 82
     );
83
-  }
83
+    }
84 84
 
85 85
 
86
-  private function getProviderConfig(string $providerName): ?array
87
-  {
86
+    private function getProviderConfig(string $providerName): ?array
87
+    {
88 88
 
89 89
     $myCompany = $this->peopleRoleService->getMainCompany();
90 90
     if ($myCompany instanceof People) {
91 91
 
92
-      return $this->manager->getRepository(Config::class)
92
+        return $this->manager->getRepository(Config::class)
93 93
         ->getKeyValuesByPeople(
94
-          $myCompany,
95
-          strtolower($providerName)
94
+            $myCompany,
95
+            strtolower($providerName)
96 96
         );
97 97
     }
98 98
 
99 99
     throw new \Exception('Company not found');
100
-  }
100
+    }
101 101
 
102
-  private function getDefaultProviderFromConfig(): ?string
103
-  {
102
+    private function getDefaultProviderFromConfig(): ?string
103
+    {
104 104
     $myCompany = $this->peopleRoleService->getMainCompany();
105 105
     if ($myCompany instanceof People) {
106
-      $configs = $this->manager->getRepository(Config::class)
106
+        $configs = $this->manager->getRepository(Config::class)
107 107
         ->getKeyValuesByPeople(
108
-          $myCompany,
109
-          'provider'
108
+            $myCompany,
109
+            'provider'
110 110
         );
111 111
 
112
-      if ($configs === null) {
112
+        if ($configs === null) {
113 113
         return null;
114
-      }
114
+        }
115 115
 
116
-      return isset($configs['provider-signature']) ?
116
+        return isset($configs['provider-signature']) ?
117 117
         $configs['provider-signature'] : null;
118 118
     }
119 119
 
120 120
     throw new \Exception('Company not found');
121
-  }
121
+    }
122 122
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,8 +30,9 @@  discard block
 block discarded – undo
30 30
   public function genetateFromModel(Contract $data)
31 31
   {
32 32
     $file = $data->getContractFile();
33
-    if (!$file)
34
-      $file = new File();
33
+    if (!$file) {
34
+          $file = new File();
35
+    }
35 36
 
36 37
     $file->setFileType('text');
37 38
     $file->setExtension('html');
@@ -47,8 +48,9 @@  discard block
 block discarded – undo
47 48
   {
48 49
     $content = $contract->getContractFile()->getContent();
49 50
 
50
-    if ($contract->getContractFile()->getExtension() == 'pdf')
51
-      return $content;
51
+    if ($contract->getContractFile()->getExtension() == 'pdf') {
52
+          return $content;
53
+    }
52 54
 
53 55
     if (empty($content)) {
54 56
       throw new \Exception(
Please login to merge, or discard this patch.