Completed
Push — master ( 79e9d7...833283 )
by Pavel
03:42 queued 11s
created
src/Grid/DataGridBuilder.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     public function addColumn(string $columnClass, array $config = []): DataGridBuilderInterface
45 45
     {
46 46
         if (!is_subclass_of($columnClass, AbstractColumn::class)) {
47
-            throw new InvalidArgumentException('Expected subclass of' . AbstractColumn::class);
47
+            throw new InvalidArgumentException('Expected subclass of'.AbstractColumn::class);
48 48
         }
49 49
         $this->columns[] = new $columnClass($this->container, array_merge(['template' => $this->options['template']], $config));
50 50
         return $this;
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     public function setTemplate(string $path) : DataGridBuilderInterface
67 67
     {
68 68
         $this->options['template'] = $path;
69
-        foreach ($this->columns as $column){
69
+        foreach ($this->columns as $column) {
70 70
             $column->setTemplate($path);
71 71
         }
72 72
         return $this;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 
84 84
     public function enablePagination($options = []) : DataGridBuilderInterface
85 85
     {
86
-        if (is_array($options) && !empty($options)){
86
+        if (is_array($options) && !empty($options)) {
87 87
             $this->options['pagination'] = true;
88 88
             $this->options['paginationOptions'] = $options;
89 89
         } else {
Please login to merge, or discard this patch.
src/Grid/DataGridFactory.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
         $this->gridBuilder = new DataGridBuilder($container);
58 58
         $this->filterBuilder = new DataGridFiltersBuilder($container);
59 59
         $this->options['filtersCriteria'] = $this->filterBuilder->getCriteria();
60
-        foreach ($configs->getConfigs() as $key => $value){
60
+        foreach ($configs->getConfigs() as $key => $value) {
61 61
             $setter = 'setDefault'.ucfirst($key);
62
-            if (method_exists($this, $setter)){
62
+            if (method_exists($this, $setter)) {
63 63
                 $this->$setter($value);
64 64
             }
65 65
         }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
     public function createGrid(string $gridType, ServiceEntityRepository $repository): DataGrid
70 70
     {
71 71
         if (!is_subclass_of($gridType, AbstractGridType::class)) {
72
-            throw new InvalidArgumentException('Expected subclass of ' . AbstractGridType::class);
72
+            throw new InvalidArgumentException('Expected subclass of '.AbstractGridType::class);
73 73
         }
74 74
         $this->repository = $repository;
75 75
         /** @var AbstractGridType $type */
@@ -84,20 +84,20 @@  discard block
 block discarded – undo
84 84
     protected function handleRequest(): void
85 85
     {
86 86
         $params = array_key_exists('data_grid', $this->request->query->all()) ? $this->request->query->get('data_grid') : [];
87
-        if (array_key_exists('sortBy', $params)){
87
+        if (array_key_exists('sortBy', $params)) {
88 88
             $this->setSort($params['sortBy']);
89 89
             unset($params['sortBy']);
90 90
         }
91
-        if (array_key_exists('pagination',$this->options) && $this->options['pagination']){
92
-            if (array_key_exists('page', $params)){
91
+        if (array_key_exists('pagination', $this->options) && $this->options['pagination']) {
92
+            if (array_key_exists('page', $params)) {
93 93
                 $this->setPage($params['page']);
94 94
                 unset($params['page']);
95 95
             } else {
96 96
                 $this->setPage(1);
97 97
             }
98 98
         }
99
-        foreach ($this->columns as $column){
100
-            if ($column->hasFilter() && array_key_exists($column->getAttribute(), $params)){
99
+        foreach ($this->columns as $column) {
100
+            if ($column->hasFilter() && array_key_exists($column->getAttribute(), $params)) {
101 101
                 $column->setFilterValue($params[$column->getAttribute()]);
102 102
             }
103 103
         }
@@ -106,30 +106,30 @@  discard block
 block discarded – undo
106 106
         $this->options['filtersCriteria'] = $this->filterBuilder->getCriteria();
107 107
     }
108 108
 
109
-    protected function setSort($attribute){
109
+    protected function setSort($attribute) {
110 110
         $first = substr($attribute, 0, 1);
111
-        if ($first == '-'){
112
-            $this->options['sort'] = [substr($attribute,1), 'DESC'];
111
+        if ($first == '-') {
112
+            $this->options['sort'] = [substr($attribute, 1), 'DESC'];
113 113
         } else {
114 114
             $this->options['sort'] = [$attribute, 'ASC'];
115 115
         }
116 116
     }
117 117
 
118
-    protected function setPage($page){
118
+    protected function setPage($page) {
119 119
         if (is_numeric($page))
120 120
             $this->options['page'] = (int)$page;
121 121
         else
122 122
             $this->options['page'] = 1;
123 123
     }
124 124
 
125
-    protected function setDefaultTemplate($template){
125
+    protected function setDefaultTemplate($template) {
126 126
         $this->gridBuilder->setTemplate($template);
127 127
     }
128
-    protected function setDefaultNoDataMessage($message){
128
+    protected function setDefaultNoDataMessage($message) {
129 129
         $this->gridBuilder->setNoDataMessage($message);
130 130
     }
131
-    protected function setDefaultPagination($pagination){
132
-        if ($pagination['enabled']){
131
+    protected function setDefaultPagination($pagination) {
132
+        if ($pagination['enabled']) {
133 133
             $this->gridBuilder->enablePagination($pagination['options']);
134 134
         }
135 135
     }
Please login to merge, or discard this patch.