Passed
Pull Request — master (#78)
by guillaume
08:26
created
app/Src/UseCases/Domain/Context/UseCases/AddCharacteristicsToContext.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,9 +38,9 @@
 block discarded – undo
38 38
         $pages = $this->pageRepository->getByIds($pagesIds);
39 39
 
40 40
         $characteristics = [];
41
-        foreach ($pages as $page){
41
+        foreach ($pages as $page) {
42 42
             $characteristic = $this->characteristicsRepository->getByPageId($page->pageId());
43
-            if(!isset($characteristic)){
43
+            if (!isset($characteristic)) {
44 44
                 $type = $page->type() === 'Culture' ? Characteristic::FARMING_TYPE : Characteristic::CROPPING_SYSTEM;
45 45
                 $characteristic = new Characteristic(
46 46
                     Uuid::uuid4(),
Please login to merge, or discard this patch.
app/Src/UseCases/Domain/Context/Queries/GetUserPractises.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
     {
20 20
         $practisesToReturn = [];
21 21
         $practises = $this->interactionsRepository->getDoneByUser($userId);
22
-        foreach ($practises as $practise){
22
+        foreach ($practises as $practise) {
23 23
             $year = $practise->doneAt() !== null ? $practise->doneAt()->format('Y') : 'Non datée';
24 24
             $practisesToReturn[$year][] = $practise->toArray();
25 25
         }
Please login to merge, or discard this patch.
app/Console/Commands/SyncDryPagesFromWiki.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     {
25 25
         $httpClient = new Client();
26 26
 
27
-        PageModel::query()->where('dry', true)->chunkById(50, function ($items, $count) use($httpClient){
27
+        PageModel::query()->where('dry', true)->chunkById(50, function($items, $count) use($httpClient){
28 28
             $this->info(($count*50).' Pages');
29 29
             $pages = $items->pluck('page_id')->toArray();
30 30
             $pagesApiUri = config('wiki.api_uri').$this->queryPages.implode('|', $pages);
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
             $content = json_decode($response->getBody()->getContents(), true);
33 33
             $wikiPages = $content['query']['pages'];
34 34
 
35
-            foreach($wikiPages as $page){
35
+            foreach ($wikiPages as $page) {
36 36
                 $pageModel = PageModel::query()->where('page_id', $page['pageid'])->first();
37 37
 
38 38
                 if (!isset($page['title']))
Please login to merge, or discard this patch.
app/Src/UseCases/Infra/Sql/InteractionPageRepositorySql.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@
 block discarded – undo
124 124
      * @param string|null $characteristicIdCroppingSystem
125 125
      * @return Paginator
126 126
      *
127
-    */
127
+     */
128 128
 
129 129
     public function getFollowersPage(int $pageId, string $type = 'follow', ?string $departmentNumber = null, ?string $characteristicId = null, ?string $characteristicIdCroppingSystem = null): Paginator
130 130
     {
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -130,8 +130,9 @@
 block discarded – undo
130 130
     {
131 131
         // Handle Corsica differently:
132 132
         if (strtolower($departmentNumber) == '2a' ||
133
-            strtolower($departmentNumber) == '2b')
134
-            $departmentNumber = '20';
133
+            strtolower($departmentNumber) == '2b') {
134
+                    $departmentNumber = '20';
135
+        }
135 136
 
136 137
         return  InteractionModel::query()
137 138
             ->with('user.context')
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
             ->where('page_id', $interaction->pageId())
27 27
             ->first();
28 28
 
29
-        if($interactionModel === null) {
29
+        if ($interactionModel === null) {
30 30
             $interactionModel = new InteractionModel();
31 31
             $interactionModel->{$canInteract->key()} = isset($user->id) ? $user->id : $canInteract->identifier();
32 32
         }
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
     public function getByInteractUser(CanInteract $canInteract, int $pageId): ?Interaction
40 40
     {
41
-        if($canInteract->key() == 'user_id') {
41
+        if ($canInteract->key() == 'user_id') {
42 42
             $user = User::query()->where('uuid', $canInteract->identifier())->first();
43 43
         }
44 44
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
             ->where('page_id', $pageId)
48 48
             ->first();
49 49
 
50
-        if(!isset($interactionModel)){
50
+        if (!isset($interactionModel)) {
51 51
             return null;
52 52
         }
53 53
 
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
             ->orderBy('updated_at', 'desc')
84 84
             ->get();
85 85
 
86
-        foreach($interactionsModel as $interaction) {
86
+        foreach ($interactionsModel as $interaction) {
87 87
             $page = PageModel::query()->where('page_id', $interaction->page_id)->first();
88
-            if(!isset($page)){
88
+            if (!isset($page)) {
89 89
                 continue;
90 90
             }
91 91
             $applause = InteractionModel::query()->where('page_id', $interaction->page_id)->where('applause', true)->count();
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
             ->where('user_id', $user->id)
109 109
             ->where('done', true)
110 110
             ->get();
111
-        foreach ($records as $record){
111
+        foreach ($records as $record) {
112 112
             $practises[] = new PractiseVo(
113 113
                 $record->page_id,
114 114
                 $record->page->title ?? '',
@@ -138,18 +138,18 @@  discard block
 block discarded – undo
138 138
 
139 139
         return  InteractionModel::query()
140 140
             ->with('user.context')
141
-            ->where(function ($query) use ($type){
142
-                $query->when($type === 'follow', function ($query) {
141
+            ->where(function($query) use ($type){
142
+                $query->when($type === 'follow', function($query) {
143 143
                     $query->where('follow', true);
144 144
                     $query->orWhere('done', true);
145 145
                 })
146
-                ->when($type === 'do', function ($query) {
146
+                ->when($type === 'do', function($query) {
147 147
                     $query->where('done', true);
148 148
                 });
149 149
             })
150
-            ->when($characteristicId !== null, function ($query) use($characteristicId) {
150
+            ->when($characteristicId !== null, function($query) use($characteristicId) {
151 151
                 $characteristic = CharacteristicsModel::query()->where('uuid', $characteristicId)->first();
152
-                if(!isset($characteristic)){
152
+                if (!isset($characteristic)) {
153 153
                     return;
154 154
                 }
155 155
                 $query->whereRaw(
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
                     $characteristic->id
158 158
                 );
159 159
             })
160
-            ->when($characteristicIdCroppingSystem !== null, function ($query) use($characteristicIdCroppingSystem) {
160
+            ->when($characteristicIdCroppingSystem !== null, function($query) use($characteristicIdCroppingSystem) {
161 161
                 $characteristic = CharacteristicsModel::query()->where('uuid', $characteristicIdCroppingSystem)->first();
162
-                if(!isset($characteristic)){
162
+                if (!isset($characteristic)) {
163 163
                     return;
164 164
                 }
165 165
                 $query->whereRaw(
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
                     $characteristic->id
168 168
                 );
169 169
             })
170
-            ->when($departmentNumber !== null, function ($query) use($departmentNumber) {
170
+            ->when($departmentNumber !== null, function($query) use($departmentNumber) {
171 171
                 $query
172 172
                     ->join('users', 'users.id', 'interactions.user_id')
173 173
                     ->join('contexts', 'users.context_id', 'contexts.id')
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
             ->whereNotNull('interactions.user_id')
178 178
             ->orderBy('interactions.updated_at', 'desc')
179 179
             ->paginate()
180
-            ->through(function ($item){
180
+            ->through(function($item) {
181 181
                 return $item->user->context->toDto($item->user->uuid, $item->start_done_at ? $item->start_done_at->format('Y-m-d') : $item->done);
182 182
             })
183 183
         ;
Please login to merge, or discard this patch.
app/Src/UseCases/Infra/Sql/Model/ContextModel.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@
 block discarded – undo
23 23
 
24 24
     public function toDto(?string $userUid = null, $hasDone = false):ContextDto
25 25
     {
26
-        $characteristics = $this->user->characteristics()->get()->transform(function(CharacteristicsModel $item){
26
+        $characteristics = $this->user->characteristics()->get()->transform(function(CharacteristicsModel $item) {
27 27
             return $item->toDto();
28 28
         });
29 29
 
30 30
         $numberDepartment = (new PostalCode($this->postal_code))->department();
31 31
         $characteristicDepartment = CharacteristicsModel::query()->where('code', $numberDepartment)->first();
32 32
 
33
-        if(isset($characteristicDepartment)){
33
+        if (isset($characteristicDepartment)) {
34 34
             $characteristics->push($characteristicDepartment->toDto());
35 35
         }
36 36
 
Please login to merge, or discard this patch.
app/Src/UseCases/Infra/Sql/ReportingCharacteristicSql.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -18,12 +18,12 @@  discard block
 block discarded – undo
18 18
             ')
19 19
             ->join('users', 'users.id', 'interactions.user_id')
20 20
             ->join('contexts', 'users.context_id', 'contexts.id')
21
-            ->where(function ($query) use ($type){
22
-                $query->when($type === 'follow', function ($query) {
21
+            ->where(function($query) use ($type){
22
+                $query->when($type === 'follow', function($query) {
23 23
                     $query->where('follow', true);
24 24
                     $query->orWhere('done', true);
25 25
                 })
26
-                        ->when($type === 'do', function ($query) {
26
+                        ->when($type === 'do', function($query) {
27 27
                             $query->where('done', true);
28 28
                         });
29 29
             })
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
             ->get();
34 34
 
35 35
         $interactionsToReturn = [];
36
-        foreach($interactions as $interaction){
36
+        foreach ($interactions as $interaction) {
37 37
             $characteristicsModel = CharacteristicsModel::query()->where('code', $interaction->department)->first();
38 38
 
39 39
             // FIXME : This test is only necessary because corsica breaks the line above. When corsica is correctly handled,
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
             ->join('contexts', 'users.context_id', 'contexts.id')
59 59
             ->join('user_characteristics', 'user_characteristics.user_id', 'users.id')
60 60
             ->join('characteristics', 'characteristics.id', 'user_characteristics.characteristic_id')
61
-            ->where(function ($query) use ($type){
62
-                $query->when($type === 'follow', function ($query) {
61
+            ->where(function($query) use ($type){
62
+                $query->when($type === 'follow', function($query) {
63 63
                     $query->where('follow', true);
64 64
                     $query->orWhere('done', true);
65 65
                 })
66
-                        ->when($type === 'do', function ($query) {
66
+                        ->when($type === 'do', function($query) {
67 67
                             $query->where('done', true);
68 68
                         });
69 69
             })
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
             ->get();
77 77
 
78 78
         $characteristicsToReturn = [];
79
-        foreach($characteristicsCount as $characteristicCount){
79
+        foreach ($characteristicsCount as $characteristicCount) {
80 80
             $characteristic = CharacteristicsModel::query()->find($characteristicCount->characteristic_id);
81 81
             $characteristic->count = $characteristicCount->count;
82 82
             $c = $characteristic->toArray();
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,8 +38,9 @@
 block discarded – undo
38 38
 
39 39
             // FIXME : This test is only necessary because corsica breaks the line above. When corsica is correctly handled,
40 40
             // we should remove the test for emptyness.
41
-            if (!empty($characteristicsModel))
42
-                $characteristicsModel->icon = route('api.icon.serve', ['id' => $characteristicsModel->uuid]);
41
+            if (!empty($characteristicsModel)) {
42
+                            $characteristicsModel->icon = route('api.icon.serve', ['id' => $characteristicsModel->uuid]);
43
+            }
43 44
 
44 45
             $interaction->departmentData = $characteristicsModel;
45 46
             $interactionsToReturn[] = $interaction->toArray();
Please login to merge, or discard this patch.
app/User.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     public function adminlte_image()
37 37
     {
38 38
         $urlPicture = $this->path_picture != "" ? asset('storage/'.str_replace('app/public/', '', $this->path_picture)) : null;
39
-        if(!isset($urlPicture) || $urlPicture === ""){
39
+        if (!isset($urlPicture) || $urlPicture === "") {
40 40
             $urlPicture = url('').'/'.config('adminlte.logo_img');
41 41
         }
42 42
         return $urlPicture;
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     public function adminlte_desc()
46 46
     {
47 47
         $desc = $this->firstname.' '.$this->lastname;
48
-        if($this->organization_id !== null){
48
+        if ($this->organization_id !== null) {
49 49
             $organization = app(OrganizationRepository::class)->get($this->organization_id);
50 50
             $desc .= ' - organisme : '.$organization->name();
51 51
         }
Please login to merge, or discard this patch.
app/Src/UseCases/Domain/User.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -61,14 +61,14 @@  discard block
 block discarded – undo
61 61
         return $this->firstname.' '.$this->lastname;
62 62
     }
63 63
 
64
-    public function organizationId():?string
64
+    public function organizationId(): ?string
65 65
     {
66 66
         return $this->organizationId;
67 67
     }
68 68
 
69 69
     public function provider(string $provider, string $providerId):bool
70 70
     {
71
-        if(isset($this->providers[$provider]) && $this->providers[$provider] == $providerId){
71
+        if (isset($this->providers[$provider]) && $this->providers[$provider] == $providerId) {
72 72
             return true;
73 73
         }
74 74
         return false;
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 
88 88
     public function create(string $passwordHashed = null, Picture $picture = null)
89 89
     {
90
-        if(isset($picture)) {
91
-            $picture->resize('app/public/users/' . $this->id);
90
+        if (isset($picture)) {
91
+            $picture->resize('app/public/users/'.$this->id);
92 92
             $this->pathPicture = $picture->relativePath();
93 93
         }
94 94
         app(UserRepository::class)->add($this, $passwordHashed);
@@ -130,20 +130,20 @@  discard block
 block discarded – undo
130 130
         $this->email = $email;
131 131
         $this->firstname = $firstname;
132 132
         $this->lastname = $lastname;
133
-        if($pathPicture !== "") {
133
+        if ($pathPicture !== "") {
134 134
             $picture = new Picture($pathPicture);
135
-            $picture->resize('app/public/users/' . $this->id . '.' . $ext);
136
-            $this->pathPicture = 'app/public/users/' . $this->id . '.' . $ext;
135
+            $picture->resize('app/public/users/'.$this->id.'.'.$ext);
136
+            $this->pathPicture = 'app/public/users/'.$this->id.'.'.$ext;
137 137
         }
138 138
         app(UserRepository::class)->update($this);
139 139
     }
140 140
 
141 141
     public function updateAvatar(string $pathPicture, string $ext = 'jpg')
142 142
     {
143
-        if($pathPicture !== "") {
143
+        if ($pathPicture !== "") {
144 144
             $picture = new Picture($pathPicture);
145
-            $picture->resize('app/public/users/' . $this->id . '.' . $ext);
146
-            $this->pathPicture = 'app/public/users/' . $this->id . '.' . $ext;
145
+            $picture->resize('app/public/users/'.$this->id.'.'.$ext);
146
+            $this->pathPicture = 'app/public/users/'.$this->id.'.'.$ext;
147 147
         }
148 148
         app(UserRepository::class)->update($this);
149 149
         return $this->pathPicture;
Please login to merge, or discard this patch.
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.