Skip to content

Commit fc85b8f

Browse files
karam-mustafaactions-user
authored andcommitted
Fix styling
1 parent bc4dff7 commit fc85b8f

File tree

10 files changed

+27
-44
lines changed

10 files changed

+27
-44
lines changed

.php-cs-fixer.cache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"php":"8.1.1","version":"3.5.0","indent":" ","lineEnding":"\n","rules":{"blank_line_after_opening_tag":true,"braces":{"allow_single_line_anonymous_class_with_empty_body":true},"class_definition":{"space_before_parenthesis":true},"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"sort_algorithm":"alpha"},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"class_attributes_separation":{"elements":{"method":"one"}}},"hashes":{"src\/Providers\/ClassToBuildServiceProviders.php":894462343,"src\/Classes\/ClassToBuild.php":1863686418,"src\/Abstracts\/AbstractToBuild.php":4067261489,"src\/Interfaces\/ClassToBuildInterface.php":3639279532,"src\/Commands\/InstallCommand.php":800925523,"src\/Config\/package_config.php":1122705014,"src\/Facades\/ClassToBuildFacade.php":3267118586,"tests\/Feature\/ExampleTest.php":3639981892,"tests\/BaseTest.php":3538535820}}
1+
{"php":"8.1.1","version":"3.5.0","indent":" ","lineEnding":"\n","rules":{"blank_line_after_opening_tag":true,"braces":{"allow_single_line_anonymous_class_with_empty_body":true},"class_definition":{"space_before_parenthesis":true},"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"sort_algorithm":"alpha"},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"class_attributes_separation":{"elements":{"method":"one"}}},"hashes":{"src\/Providers\/ClassToBuildServiceProviders.php":894462343,"src\/Classes\/ClassToBuild.php":1863686418,"src\/Abstracts\/AbstractToBuild.php":4067261489,"src\/Interfaces\/ClassToBuildInterface.php":3639279532,"src\/Commands\/InstallCommand.php":3981754395,"src\/Config\/package_config.php":1122705014,"src\/Facades\/ClassToBuildFacade.php":3267118586,"tests\/Feature\/ExampleTest.php":3403803516,"tests\/BaseTest.php":364171998,"src\/Facade\/QueryHelperFacade.php":1424222852,"src\/Providers\/QueryHelperServiceProviders.php":608029189,"src\/Classes\/DeleteHelper.php":3423337787,"src\/Classes\/JoinHelper.php":941291578,"src\/Classes\/QueryHelper.php":4113349496,"src\/Classes\/BaseHelper.php":2396364014,"src\/Classes\/InsertHelper.php":3586087926,"src\/Classes\/UpdateHelper.php":3622326637,"src\/Config\/query_helper.php":3245707786}}

src/Classes/BaseHelper.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<?php
22

3-
43
namespace SOS\QueryHelper\Classes;
54

6-
75
use Illuminate\Support\Facades\DB;
86

97
abstract class BaseHelper
@@ -53,11 +51,12 @@ protected function getAllowedWhereInQueryNumber()
5351
public function setAllowedWhereInQueryNumber($allowedWhereInQueryNumber)
5452
{
5553
$this->allowedWhereInQueryNumber = $allowedWhereInQueryNumber;
54+
5655
return $this;
5756
}
5857

5958
/**
60-
* @var boolean
59+
* @var bool
6160
*/
6261
private $isSelectStatus = false;
6362

@@ -100,7 +99,7 @@ public function setSelection($selection)
10099
}
101100

102101
/**
103-
* @param boolean $implode
102+
* @param bool $implode
104103
*
105104
* @return string
106105
* @author karam mustaf
@@ -110,6 +109,7 @@ protected function getSelection($implode = true)
110109
if ($implode) {
111110
return implode(',', $this->selection);
112111
}
112+
113113
return $this->selection;
114114
}
115115

@@ -195,6 +195,7 @@ protected function getValues()
195195
public function setValues($values)
196196
{
197197
$this->values = $values;
198+
198199
return $this;
199200
}
200201

@@ -236,8 +237,8 @@ protected function getIds()
236237
public function setIds($ids)
237238
{
238239
$this->ids = $ids;
239-
return $this;
240240

241+
return $this;
241242
}
242243

243244
/**
@@ -276,18 +277,19 @@ public function setSavedItems($savedItems)
276277
*/
277278
public function checkIfQueryAllowed($ids, $callbackIfPassed = null, $chunkCountAllowed = null)
278279
{
279-
if (!isset($chunckCountAllowed)) {
280+
if (! isset($chunckCountAllowed)) {
280281
$chunkCountAllowed = $this->getAllowedWhereInQueryNumber();
281282
}
282283

283284
$items = [];
284285
$lists = collect($ids)->chunk($chunkCountAllowed + 1);
285-
if (!is_null($callbackIfPassed)) {
286+
if (! is_null($callbackIfPassed)) {
286287
foreach ($lists as $index => $list) {
287288
$items[] = $callbackIfPassed($list, $index);
288289
}
289290
}
290291
$this->savedItems = $items;
292+
291293
return $items;
292294
}
293295

@@ -362,7 +364,7 @@ protected function checkIfInteger($index)
362364
* loop through specific array and each iteration will execute by a callback.
363365
*
364366
* @param array $arr
365-
* @param callback $callback
367+
* @param callable $callback
366368
*
367369
* @return void
368370
* @author karam mustafa

src/Classes/DeleteHelper.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<?php
22

3-
43
namespace SOS\QueryHelper\Classes;
54

6-
75
use Illuminate\Support\Facades\DB;
86

97
/**
@@ -14,7 +12,6 @@
1412
*/
1513
class DeleteHelper extends BaseHelper
1614
{
17-
1815
/**
1916
* drop multiple tables by their names in the database
2017
*

src/Classes/InsertHelper.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
<?php
22

3-
43
namespace SOS\QueryHelper\Classes;
54

6-
75
class InsertHelper extends BaseHelper
86
{
9-
107
}

src/Classes/JoinHelper.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<?php
22

3-
43
namespace SOS\QueryHelper\Classes;
54

6-
use \Illuminate\Support\Str;
5+
use Illuminate\Support\Str;
76

87
/**
98
* Class JoinHelper
@@ -13,7 +12,6 @@
1312
*/
1413
class JoinHelper extends BaseHelper
1514
{
16-
1715
/**
1816
*
1917
* @author karam mustafa
@@ -70,19 +68,21 @@ public function buildJoin($saveItems = true)
7068
{
7169
// set the select query.
7270
$this->setQuery(
73-
sprintf("SELECT %s FROM %s %s",
71+
sprintf(
72+
"SELECT %s FROM %s %s",
7473
$this->getSelection(),
7574
$this->getTableName(),
7675
$this->getQuery()
77-
));
76+
)
77+
);
7878
// change the selection status to isSelectStatus,
7979
// so we can execute this query as a raw statement.
8080
$this->setIsSelectStatus();
8181
// check if we want to execute the query and save the results.
8282
if ($saveItems) {
8383
// save this result in savedItems Property
8484
$this->setSavedItems([
85-
$this->savedKey => $this->executeAll()
85+
$this->savedKey => $this->executeAll(),
8686
]);
8787
}
8888

@@ -118,15 +118,15 @@ public function resolveRelation($firstTable, $secondTable)
118118
*/
119119
public function fastJoin($mainTableName, $selection, $tables, $joinTypes = 'JOIN')
120120
{
121-
$tables = !is_array($tables) ? [$tables] : $tables;
121+
$tables = ! is_array($tables) ? [$tables] : $tables;
122122
// this is a important step if the user has been execute multi fastJoin
123123
// because the clearAll function clear the default field.
124124
$this->setField('id');
125125
// build the join query
126126
$this->buildFastJoin($mainTableName, $selection, $tables, $joinTypes);
127127
// clear all parameter's, except the saved items.
128128
$this->clearAll();
129-
129+
130130
return $this;
131131
}
132132

@@ -188,9 +188,8 @@ private function buildFastJoin($mainTableName, $selection, $tables, $joinTypes):
188188
->setSelection($selection)
189189
->setJoinType($joinTypes)
190190
->buildJoin(false)
191-
->executeAll()
191+
->executeAll(),
192192
]);
193-
194193
});
195194
}
196195
}

src/Classes/QueryHelper.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<?php
22

3-
43
namespace SOS\QueryHelper\Classes;
54

6-
75
/**
86
* Class QueryHelper
97
*
@@ -44,10 +42,10 @@ class QueryHelper extends BaseHelper
4442
public function __construct()
4543
{
4644
$this->initContainer(
47-
new UpdateHelper,
48-
new DeleteHelper,
49-
new InsertHelper,
50-
new JoinHelper
45+
new UpdateHelper(),
46+
new DeleteHelper(),
47+
new InsertHelper(),
48+
new JoinHelper()
5149
);
5250
$this->setAllowedWhereInQueryNumber(config('query_helper.allowed_chunk_number'));
5351
}
@@ -114,5 +112,4 @@ public function initContainer($updateHelper, $deleteHelper, $insertHelper, $join
114112
$this->insertHelper = $insertHelper;
115113
$this->joinHelper = $joinHelper;
116114
}
117-
118115
}

src/Classes/UpdateHelper.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
<?php
22

3-
43
namespace SOS\QueryHelper\Classes;
54

6-
75
class UpdateHelper extends BaseHelper
86
{
9-
107
/**
118
* @var mixed
129
*/
@@ -29,6 +26,7 @@ public function getCases()
2926
public function setCases($cases)
3027
{
3128
$this->cases = $cases;
29+
3230
return $this;
3331
}
3432

@@ -52,7 +50,6 @@ public function executeUpdateMultiRows($key = null)
5250
$this->buildStatement()->executeAll();
5351

5452
return $this;
55-
5653
} catch (\Exception $e) {
5754
throw new \Exception($e->getMessage());
5855
}
@@ -83,7 +80,6 @@ public function buildStatement()
8380
$this->setQuery($query);
8481

8582
return $this;
86-
8783
} catch (\Exception $e) {
8884
throw new \Exception($e->getMessage());
8985
}
@@ -134,6 +130,7 @@ public function fastUpdate($tableName, $ids, $vales, $column)
134130
->setField($column)
135131
->bindIdsWithValues()
136132
->executeUpdateMultiRows();
133+
137134
return $this;
138135
}
139136
}

src/Commands/InstallCommand.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
<?php
22

3-
43
namespace SOS\QueryHelper\Commands;
54

6-
75
use Illuminate\Console\Command;
86
use Illuminate\Support\Facades\Artisan;
97

108
class InstallCommand extends Command
119
{
12-
1310
public $packageLink = 'https://github.com/karam-mustafa/laravel-query-helper';
1411

1512
/**

src/Facade/QueryHelperFacade.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
43
namespace SOS\QueryHelper\Facade;
54

65
use Illuminate\Support\Facades\Facade;

src/Providers/QueryHelperServiceProviders.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515
class QueryHelperServiceProviders extends ServiceProvider
1616
{
17-
1817
/**
1918
*
2019
*
@@ -53,7 +52,7 @@ protected function registerFacades()
5352
protected function publishesPackages()
5453
{
5554
$this->publishes([
56-
__DIR__."/../Config/query_helper.php" => config_path("query_helper.php")
55+
__DIR__."/../Config/query_helper.php" => config_path("query_helper.php"),
5756
], "query-helper-config");
5857
}
5958

@@ -70,5 +69,4 @@ private function resolveCommands()
7069
]);
7170
}
7271
}
73-
7472
}

0 commit comments

Comments
 (0)