Passed
Pull Request — master (#78)
by guillaume
08:26
created
app/Src/UseCases/Infra/Sql/ContextRepositorySql.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
 
16 16
 class ContextRepositorySql implements ContextRepository
17 17
 {
18
-    public function getByUser(string $userId):?Context
18
+    public function getByUser(string $userId): ?Context
19 19
     {
20 20
         $user = User::where('uuid', $userId)->first();
21 21
         $context = DB::table('contexts')->where('id', $user->context_id)->first();
22
-        if($context == null){
22
+        if ($context == null) {
23 23
             return null;
24 24
         }
25 25
         return new Context(
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
         $user = User::where('uuid', $userId)->first();
39 39
 
40 40
         $farmings = $contextData->get('farmings');
41
-        foreach($farmings as $farming){
42
-            $characteristic = CharacteristicsModel::where('uuid', (string)$farming)->first();
41
+        foreach ($farmings as $farming) {
42
+            $characteristic = CharacteristicsModel::where('uuid', (string) $farming)->first();
43 43
             $user->characteristics()->save($characteristic);
44 44
         }
45 45
 
@@ -52,21 +52,21 @@  discard block
 block discarded – undo
52 52
     public function getByUserDto(string $userId): ?ContextDto
53 53
     {
54 54
         $user = User::where('uuid', $userId)->first();
55
-        if($user == null){
55
+        if ($user == null) {
56 56
             return null;
57 57
         }
58 58
         $context = ContextModel::find($user->context_id);
59
-        if($context == null){
59
+        if ($context == null) {
60 60
             return null;
61 61
         }
62
-        $characteristics = $user->characteristics()->get()->transform(function(CharacteristicsModel $item){
62
+        $characteristics = $user->characteristics()->get()->transform(function(CharacteristicsModel $item) {
63 63
             return $item->toDto();
64 64
         });
65 65
 
66 66
         $numberDepartment = (new PostalCode($context->postal_code))->department();
67 67
         $characteristicDepartment = CharacteristicsModel::query()->where('code', $numberDepartment)->first();
68 68
 
69
-        if(isset($characteristicDepartment)){
69
+        if (isset($characteristicDepartment)) {
70 70
             $characteristics->push($characteristicDepartment->toDto());
71 71
         }
72 72
 
@@ -84,12 +84,12 @@  discard block
 block discarded – undo
84 84
     public function update(Context $context, string $userId)
85 85
     {
86 86
         $user = User::where('uuid', $userId)->first();
87
-        if($user === null){
87
+        if ($user === null) {
88 88
             return null;
89 89
         }
90 90
 
91 91
         $contextModel = ContextModel::where('uuid', $context->id())->first();
92
-        if($contextModel === null){
92
+        if ($contextModel === null) {
93 93
             return null;
94 94
         }
95 95
         $contextData = collect($context->toArray());
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 
98 98
         $farmings = $contextData->get('farmings');
99 99
         $characteristics = [];
100
-        foreach($farmings as $farming){
101
-            $characteristicModel = CharacteristicsModel::where('uuid', (string)$farming)->first();
102
-            if(isset($characteristicModel)) {
100
+        foreach ($farmings as $farming) {
101
+            $characteristicModel = CharacteristicsModel::where('uuid', (string) $farming)->first();
102
+            if (isset($characteristicModel)) {
103 103
                 $characteristics[] = $characteristicModel->id;
104 104
             }
105 105
         }
Please login to merge, or discard this patch.
app/Src/UseCases/Domain/Ports/ContextRepository.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@
 block discarded – undo
9 9
 
10 10
 interface ContextRepository
11 11
 {
12
-    public function getByUser(string $userId):?Context;
12
+    public function getByUser(string $userId): ?Context;
13 13
     public function add(Context $context, string $userId);
14 14
     public function update(Context $context, string $userId);
15
-    public function getByUserDto(string $userId):?ContextDto;
15
+    public function getByUserDto(string $userId): ?ContextDto;
16 16
 }
Please login to merge, or discard this patch.
app/Src/UseCases/Domain/System/GetDepartmentFromPostalCodeImpl.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
         $content = json_decode($response->getBody()->getContents(), true);
24 24
 
25 25
         $features = $content['features'];
26
-        if(isset($features) && !empty($features)){
26
+        if (isset($features) && !empty($features)) {
27 27
             $feature = $features[0];
28 28
             $coordinates = $feature['geometry']['coordinates'];
29 29
             $departmentNumber = explode(',', $feature['properties']['context'])[0];
Please login to merge, or discard this patch.