Passed
Pull Request — master (#78)
by guillaume
06:35
created
app/Src/UseCases/Infra/Sql/InteractionPageRepositorySql.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@
 block discarded – undo
126 126
      * @param string|null $characteristicIdCroppingSystem
127 127
      * @return Paginator
128 128
      *
129
-    */
129
+     */
130 130
     public function getFollowersPage(int $pageId, string $type = 'follow', ?string $departmentNumber = null, ?string $characteristicId = null, ?string $characteristicIdCroppingSystem = null): Paginator
131 131
     {
132 132
         return  InteractionModel::query()
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
             ->where('page_id', $interaction->pageId())
26 26
             ->first();
27 27
 
28
-        if($interactionModel === null) {
28
+        if ($interactionModel === null) {
29 29
             $interactionModel = new InteractionModel();
30 30
             $interactionModel->{$canInteract->key()} = isset($user->id) ? $user->id : $canInteract->identifier();
31 31
         }
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
     public function getByInteractUser(CanInteract $canInteract, int $pageId): ?Interaction
39 39
     {
40
-        if($canInteract->key() == 'user_id') {
40
+        if ($canInteract->key() == 'user_id') {
41 41
             $user = User::query()->where('uuid', $canInteract->identifier())->first();
42 42
         }
43 43
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
             ->where('page_id', $pageId)
47 47
             ->first();
48 48
 
49
-        if(!isset($interactionModel)){
49
+        if (!isset($interactionModel)) {
50 50
             return null;
51 51
         }
52 52
 
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
             ->orderBy('updated_at', 'desc')
83 83
             ->get();
84 84
 
85
-        foreach($interactionsModel as $interaction) {
85
+        foreach ($interactionsModel as $interaction) {
86 86
             $page = PageModel::query()->where('page_id', $interaction->page_id)->first();
87
-            if(!isset($page)){
87
+            if (!isset($page)) {
88 88
                 continue;
89 89
             }
90 90
             $applause = InteractionModel::query()->where('page_id', $interaction->page_id)->where('applause', true)->count();
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
             ->where('user_id', $user->id)
108 108
             ->where('done', true)
109 109
             ->get();
110
-        foreach ($records as $record){
110
+        foreach ($records as $record) {
111 111
             $practises[] = new PractiseVo(
112 112
                 $record->page_id,
113 113
                 $record->page->title ?? '',
@@ -131,18 +131,18 @@  discard block
 block discarded – undo
131 131
     {
132 132
         return  InteractionModel::query()
133 133
             ->with('user.context')
134
-            ->where(function ($query) use ($type){
135
-                $query->when($type === 'follow', function ($query) {
134
+            ->where(function($query) use ($type){
135
+                $query->when($type === 'follow', function($query) {
136 136
                     $query->where('follow', true);
137 137
                     $query->orWhere('done', true);
138 138
                 })
139
-                ->when($type === 'do', function ($query) {
139
+                ->when($type === 'do', function($query) {
140 140
                     $query->where('done', true);
141 141
                 });
142 142
             })
143
-            ->when($characteristicId !== null, function ($query) use($characteristicId) {
143
+            ->when($characteristicId !== null, function($query) use($characteristicId) {
144 144
                 $characteristic = CharacteristicsModel::query()->where('uuid', $characteristicId)->first();
145
-                if(!isset($characteristic)){
145
+                if (!isset($characteristic)) {
146 146
                     return;
147 147
                 }
148 148
                 $query->whereRaw(
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
                     $characteristic->id
151 151
                 );
152 152
             })
153
-            ->when($characteristicIdCroppingSystem !== null, function ($query) use($characteristicIdCroppingSystem) {
153
+            ->when($characteristicIdCroppingSystem !== null, function($query) use($characteristicIdCroppingSystem) {
154 154
                 $characteristic = CharacteristicsModel::query()->where('uuid', $characteristicIdCroppingSystem)->first();
155
-                if(!isset($characteristic)){
155
+                if (!isset($characteristic)) {
156 156
                     return;
157 157
                 }
158 158
                 $query->whereRaw(
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                     $characteristic->id
161 161
                 );
162 162
             })
163
-            ->when($departmentNumber !== null, function ($query) use($departmentNumber) {
163
+            ->when($departmentNumber !== null, function($query) use($departmentNumber) {
164 164
                 $query
165 165
                     ->join('users', 'users.id', 'interactions.user_id')
166 166
                     ->join('contexts', 'users.context_id', 'contexts.id')
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
             ->whereNotNull('interactions.user_id')
171 171
             ->orderBy('interactions.updated_at', 'desc')
172 172
             ->paginate()
173
-            ->through(function ($item){
173
+            ->through(function($item) {
174 174
                 return $item->user->context->toDto($item->user->uuid, $item->start_done_at ? $item->start_done_at->format('Y-m-d') : $item->done);
175 175
             })
176 176
         ;
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
@@ -25,12 +25,12 @@
 block discarded – undo
25 25
 
26 26
     public function toDto(?string $userUid = null, $hasDone = false):ContextDto
27 27
     {
28
-        $characteristics = $this->user->characteristics()->get()->transform(function(CharacteristicsModel $item){
28
+        $characteristics = $this->user->characteristics()->get()->transform(function(CharacteristicsModel $item) {
29 29
             return $item->toDto();
30 30
         });
31 31
         $characteristicDepartment = CharacteristicsModel::query()->where('code', $this->department_number)->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/Domain/Context/Dto/ContextDto.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
         $this->postalCode = $postalCode;
39 39
         $this->department = $departmentNumber;
40 40
         $this->characteristics = $characteristics;
41
-        foreach($this->characteristics as $characteristic){
41
+        foreach ($this->characteristics as $characteristic) {
42 42
             $this->characteristicsByType[$characteristic->type()][] = $characteristic;
43 43
         }
44 44
         $this->description = $description;
Please login to merge, or discard this patch.
app/Src/UseCases/Infra/Sql/ContextRepositorySql.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 class ContextRepositorySql implements ContextRepository
15 15
 {
16
-    public function getByUser(string $userId):?Context
16
+    public function getByUser(string $userId): ?Context
17 17
     {
18 18
         $user = User::where('uuid', $userId)->first();
19 19
         return $user->context !== null ? $user->context->toDomain() : null;
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
         $user = User::where('uuid', $userId)->first();
26 26
 
27 27
         $farmings = $contextData->get('farmings');
28
-        foreach($farmings as $farming){
29
-            $characteristic = CharacteristicsModel::where('uuid', (string)$farming)->first();
28
+        foreach ($farmings as $farming) {
29
+            $characteristic = CharacteristicsModel::where('uuid', (string) $farming)->first();
30 30
             $user->characteristics()->save($characteristic);
31 31
         }
32 32
 
@@ -39,20 +39,20 @@  discard block
 block discarded – undo
39 39
     public function getByUserDto(string $userId): ?ContextDto
40 40
     {
41 41
         $user = User::where('uuid', $userId)->first();
42
-        if($user == null){
42
+        if ($user == null) {
43 43
             return null;
44 44
         }
45 45
         $context = ContextModel::find($user->context_id);
46
-        if($context == null){
46
+        if ($context == null) {
47 47
             return null;
48 48
         }
49
-        $characteristics = $user->characteristics()->get()->transform(function(CharacteristicsModel $item){
49
+        $characteristics = $user->characteristics()->get()->transform(function(CharacteristicsModel $item) {
50 50
             return $item->toDto();
51 51
         });
52 52
 
53 53
         $numberDepartment = $context->department_number;
54 54
         $characteristicDepartment = CharacteristicsModel::query()->where('code', $numberDepartment)->first();
55
-        if(isset($characteristicDepartment)){
55
+        if (isset($characteristicDepartment)) {
56 56
             $characteristics->push($characteristicDepartment->toDto());
57 57
         }
58 58
 
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
     public function update(Context $context, string $userId)
74 74
     {
75 75
         $user = User::where('uuid', $userId)->first();
76
-        if($user === null){
76
+        if ($user === null) {
77 77
             return null;
78 78
         }
79 79
 
80 80
         $contextModel = ContextModel::where('uuid', $context->id())->first();
81
-        if($contextModel === null){
81
+        if ($contextModel === null) {
82 82
             return null;
83 83
         }
84 84
         $contextData = collect($context->toArray());
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
 
87 87
         $farmings = $contextData->get('farmings');
88 88
         $characteristics = [];
89
-        foreach($farmings as $farming){
90
-            $characteristicModel = CharacteristicsModel::where('uuid', (string)$farming)->first();
91
-            if(isset($characteristicModel)) {
89
+        foreach ($farmings as $farming) {
90
+            $characteristicModel = CharacteristicsModel::where('uuid', (string) $farming)->first();
91
+            if (isset($characteristicModel)) {
92 92
                 $characteristics[] = $characteristicModel->id;
93 93
             }
94 94
         }
Please login to merge, or discard this patch.