@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | public function setOptions(array $options) |
| 38 | 38 | { |
| 39 | 39 | foreach ($options as $key => $value) { |
| 40 | - $setter = 'set' . ucfirst($key); |
|
| 40 | + $setter = 'set'.ucfirst($key); |
|
| 41 | 41 | if (method_exists($this, $setter)) { |
| 42 | 42 | $this->$setter($value); |
| 43 | 43 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function getFirst() |
| 51 | 51 | { |
| 52 | - return ($this->page - 1) * $this->limit; |
|
| 52 | + return ($this->page-1) * $this->limit; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | if ($this->page < 5) { |
| 124 | 124 | return array_merge(range(1, 6), [null, $this->maxPage]); |
| 125 | 125 | } |
| 126 | - if ($this->page > $this->maxPage - 4) { |
|
| 127 | - return array_merge([1, null], range($this->maxPage - 5, $this->maxPage)); |
|
| 126 | + if ($this->page > $this->maxPage-4) { |
|
| 127 | + return array_merge([1, null], range($this->maxPage-5, $this->maxPage)); |
|
| 128 | 128 | } |
| 129 | - return array_merge([1, null], range($this->page - 2, $this->page + 2), [null, $this->maxPage]); |
|
| 129 | + return array_merge([1, null], range($this->page-2, $this->page+2), [null, $this->maxPage]); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | public function getCellContent($entity) |
| 45 | 45 | { |
| 46 | - return preg_replace_callback('/\{(\w+)\}/', function ($matches) use ($entity) { |
|
| 46 | + return preg_replace_callback('/\{(\w+)\}/', function($matches) use ($entity) { |
|
| 47 | 47 | if ($this->isButtonVisible($matches[1])) { |
| 48 | 48 | if (array_key_exists($matches[1], $this->buttons) && is_callable($this->buttons[$matches[1]])) { |
| 49 | 49 | return call_user_func_array($this->buttons[$matches[1]], [ |
@@ -76,11 +76,11 @@ discard block |
||
| 76 | 76 | if (is_callable($this->urlGenerator)) { |
| 77 | 77 | return call_user_func_array($this->urlGenerator, [$item, $action, $this->container['router']]); |
| 78 | 78 | } elseif (!empty($this->identifier) && $item->has($this->identifier)) { |
| 79 | - return $this->container['router']->generate($this->pathPrefix . $action, ['id' => $item->get($this->identifier)]); |
|
| 79 | + return $this->container['router']->generate($this->pathPrefix.$action, ['id' => $item->get($this->identifier)]); |
|
| 80 | 80 | } elseif ($item->has('id')) { |
| 81 | - return $this->container['router']->generate($this->pathPrefix . $action, ['id' => $item->get('id')]); |
|
| 81 | + return $this->container['router']->generate($this->pathPrefix.$action, ['id' => $item->get('id')]); |
|
| 82 | 82 | } else { |
| 83 | - throw new DataGridException('Could not generate url for action: ' . $action); |
|
| 83 | + throw new DataGridException('Could not generate url for action: '.$action); |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
@@ -18,10 +18,10 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | public function getItems(): array |
| 20 | 20 | { |
| 21 | - if ($this->getPager()->isEnabled()){ |
|
| 21 | + if ($this->getPager()->isEnabled()) { |
|
| 22 | 22 | $this->data = array_slice($this->data, $this->getPager()->getFirst(), $this->getPager()->getLimit()); |
| 23 | 23 | } |
| 24 | - return array_map(function ($row) { |
|
| 24 | + return array_map(function($row) { |
|
| 25 | 25 | $item = new DataGridItem(); |
| 26 | 26 | $item->setRow($row); |
| 27 | 27 | return $item; |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | public function addEqualFilter(string $attribute, $value): DataProviderInterface |
| 48 | 48 | { |
| 49 | - $this->data = array_filter($this->data, function ($row) use ($attribute, $value) { |
|
| 49 | + $this->data = array_filter($this->data, function($row) use ($attribute, $value) { |
|
| 50 | 50 | if (!array_key_exists($attribute, $row)) { |
| 51 | 51 | return false; |
| 52 | 52 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | public function addLikeFilter(string $attribute, $value): DataProviderInterface |
| 59 | 59 | { |
| 60 | - $this->data = array_filter($this->data, function ($row) use ($attribute, $value) { |
|
| 60 | + $this->data = array_filter($this->data, function($row) use ($attribute, $value) { |
|
| 61 | 61 | if (!array_key_exists($attribute, $row)) { |
| 62 | 62 | return false; |
| 63 | 63 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | public function addCustomFilter(string $attribute, $value, callable $callback): DataProviderInterface |
| 70 | 70 | { |
| 71 | - $this->data = array_filter($this->data, function ($row) use ($attribute, $value, $callback) { |
|
| 71 | + $this->data = array_filter($this->data, function($row) use ($attribute, $value, $callback) { |
|
| 72 | 72 | return call_user_func_array($callback, [$row, $attribute, $value]); |
| 73 | 73 | }); |
| 74 | 74 | return $this; |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | protected function buildCompare($attribute, $order) |
| 78 | 78 | { |
| 79 | - return function ($a, $b) use ($attribute, $order) { |
|
| 79 | + return function($a, $b) use ($attribute, $order) { |
|
| 80 | 80 | if (!array_key_exists($attribute, $a) || !array_key_exists($attribute, $b)) { |
| 81 | 81 | return 0; |
| 82 | 82 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | protected function equalDate($attribute, $value): void |
| 99 | 99 | { |
| 100 | 100 | $date = new DateTime($value); |
| 101 | - $this->data = array_filter($this->data, function ($row) use ($attribute, $date) { |
|
| 101 | + $this->data = array_filter($this->data, function($row) use ($attribute, $date) { |
|
| 102 | 102 | if (!array_key_exists($attribute, $row)) { |
| 103 | 103 | return false; |
| 104 | 104 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | protected function ltDate($attribute, $value): void |
| 118 | 118 | { |
| 119 | 119 | $date = new DateTime($value); |
| 120 | - $this->data = array_filter($this->data, function ($row) use ($attribute, $date) { |
|
| 120 | + $this->data = array_filter($this->data, function($row) use ($attribute, $date) { |
|
| 121 | 121 | if (!array_key_exists($attribute, $row)) { |
| 122 | 122 | return false; |
| 123 | 123 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | protected function lteDate($attribute, $value): void |
| 137 | 137 | { |
| 138 | 138 | $date = (new DateTime($value))->modify('+1 day'); |
| 139 | - $this->data = array_filter($this->data, function ($row) use ($attribute, $date) { |
|
| 139 | + $this->data = array_filter($this->data, function($row) use ($attribute, $date) { |
|
| 140 | 140 | if (!array_key_exists($attribute, $row)) { |
| 141 | 141 | return false; |
| 142 | 142 | } |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | protected function gtDate($attribute, $value): void |
| 156 | 156 | { |
| 157 | 157 | $date = (new DateTime($value))->modify('+1 day'); |
| 158 | - $this->data = array_filter($this->data, function ($row) use ($attribute, $date) { |
|
| 158 | + $this->data = array_filter($this->data, function($row) use ($attribute, $date) { |
|
| 159 | 159 | if (!array_key_exists($attribute, $row)) { |
| 160 | 160 | return false; |
| 161 | 161 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | protected function gteDate($attribute, $value): void |
| 175 | 175 | { |
| 176 | 176 | $date = new DateTime($value); |
| 177 | - $this->data = array_filter($this->data, function ($row) use ($attribute, $date) { |
|
| 177 | + $this->data = array_filter($this->data, function($row) use ($attribute, $date) { |
|
| 178 | 178 | if (!array_key_exists($attribute, $row)) { |
| 179 | 179 | return false; |
| 180 | 180 | } |
@@ -51,27 +51,27 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | public function addEqualFilter(string $attribute, $value): DataProviderInterface |
| 53 | 53 | { |
| 54 | - throw new DataGridException("Method addEqualFilter() is not supported in " . static::class); |
|
| 54 | + throw new DataGridException("Method addEqualFilter() is not supported in ".static::class); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | public function addLikeFilter(string $attribute, $value): DataProviderInterface |
| 58 | 58 | { |
| 59 | - throw new DataGridException("Method addLikeFilter() is not supported in " . static::class); |
|
| 59 | + throw new DataGridException("Method addLikeFilter() is not supported in ".static::class); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | public function addRelationFilter(string $attribute, $value, string $relationClass): DataProviderInterface |
| 63 | 63 | { |
| 64 | - throw new DataGridException("Method addRelationFilter() is not supported in " . static::class); |
|
| 64 | + throw new DataGridException("Method addRelationFilter() is not supported in ".static::class); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | public function addCustomFilter(string $attribute, $value, callable $callback): DataProviderInterface |
| 68 | 68 | { |
| 69 | - throw new DataGridException("Method addCustomFilter() is not supported in " . static::class); |
|
| 69 | + throw new DataGridException("Method addCustomFilter() is not supported in ".static::class); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | public function addDateFilter(string $attribute, $value, string $comparison = 'equal'): DataProviderInterface |
| 73 | 73 | { |
| 74 | - $comparisonFunc = lcfirst($comparison) . 'Date'; |
|
| 74 | + $comparisonFunc = lcfirst($comparison).'Date'; |
|
| 75 | 75 | if (method_exists($this, $comparisonFunc)) { |
| 76 | 76 | $this->$comparisonFunc($attribute, $value); |
| 77 | 77 | } else { |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | protected function equalDate($attribute, $value): void |
| 88 | 88 | { |
| 89 | - throw new DataGridException("Method equalDate() is not supported in " . static::class); |
|
| 89 | + throw new DataGridException("Method equalDate() is not supported in ".static::class); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | |
@@ -101,10 +101,10 @@ discard block |
||
| 101 | 101 | if (is_array($data)) { |
| 102 | 102 | return new ArrayDataProvider($data); |
| 103 | 103 | } |
| 104 | - throw new DataGridException('Provided data must be one of: ' . implode(', ', [ |
|
| 104 | + throw new DataGridException('Provided data must be one of: '.implode(', ', [ |
|
| 105 | 105 | ServiceEntityRepository::class, |
| 106 | 106 | QueryBuilder::class, |
| 107 | 107 | 'Array' |
| 108 | - ]) . ', ' . (($type = gettype($data)) == 'object' ? get_class($data) : $type) . ' given'); |
|
| 108 | + ]).', '.(($type = gettype($data)) == 'object' ? get_class($data) : $type).' given'); |
|
| 109 | 109 | } |
| 110 | 110 | } |