Completed
Push — master ( ae2bb1...bae126 )
by Denis
14s queued 11s
created
src/Columns/CallbackColumn.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -4,26 +4,26 @@
 block discarded – undo
4 4
 
5 5
 class CallbackColumn extends BaseColumn
6 6
 {
7
-    /**
8
-     * @var string
9
-     */
10
-    public $formatters = ['raw'];
7
+	/**
8
+	 * @var string
9
+	 */
10
+	public $formatters = ['raw'];
11 11
 
12
-    /**
13
-     * @return array
14
-     */
15
-    protected function configTests(): array
16
-    {
17
-        return array_merge(parent::configTests(), [
18
-            'value' => 'closure',
19
-        ]);
20
-    }
12
+	/**
13
+	 * @return array
14
+	 */
15
+	protected function configTests(): array
16
+	{
17
+		return array_merge(parent::configTests(), [
18
+			'value' => 'closure',
19
+		]);
20
+	}
21 21
 
22
-    /**
23
-     * @inheritdoc
24
-     */
25
-    public function _renderValue($row)
26
-    {
27
-        return call_user_func($this->value, $row);
28
-    }
22
+	/**
23
+	 * @inheritdoc
24
+	 */
25
+	public function _renderValue($row)
26
+	{
27
+		return call_user_func($this->value, $row);
28
+	}
29 29
 }
30 30
\ No newline at end of file
Please login to merge, or discard this patch.
src/Columns/ViewColumn.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@
 block discarded – undo
7 7
 
8 8
 class ViewColumn extends BaseColumn
9 9
 {
10
-    public $formatters = [];
10
+	public $formatters = [];
11 11
 
12
-    /**
13
-     * Render column value for row
14
-     * @param array|object $row
15
-     * @return string|mixed
16
-     * @throws Throwable
17
-     */
18
-    protected function _renderValue($row)
19
-    {
20
-        return view($this->value, $row)->render();
21
-    }
12
+	/**
13
+	 * Render column value for row
14
+	 * @param array|object $row
15
+	 * @return string|mixed
16
+	 * @throws Throwable
17
+	 */
18
+	protected function _renderValue($row)
19
+	{
20
+		return view($this->value, $row)->render();
21
+	}
22 22
 }
23 23
\ No newline at end of file
Please login to merge, or discard this patch.
src/Renderers/BaseRenderer.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -9,32 +9,32 @@
 block discarded – undo
9 9
 
10 10
 abstract class BaseRenderer
11 11
 {
12
-    use Configurable;
12
+	use Configurable;
13 13
 
14
-    /**
15
-     * @var GridView
16
-     */
17
-    public $gridView;
14
+	/**
15
+	 * @var GridView
16
+	 */
17
+	public $gridView;
18 18
 
19
-    /**
20
-     * BaseRenderer constructor.
21
-     * @param $config
22
-     * @throws GridViewConfigException
23
-     */
24
-    public function __construct($config)
25
-    {
26
-        $this->loadConfig($config);
27
-    }
19
+	/**
20
+	 * BaseRenderer constructor.
21
+	 * @param $config
22
+	 * @throws GridViewConfigException
23
+	 */
24
+	public function __construct($config)
25
+	{
26
+		$this->loadConfig($config);
27
+	}
28 28
 
29
-    /**
30
-     * @return array
31
-     */
32
-    protected function configTests(): array
33
-    {
34
-        return [
35
-            'gridView' => GridView::class,
36
-        ];
37
-    }
29
+	/**
30
+	 * @return array
31
+	 */
32
+	protected function configTests(): array
33
+	{
34
+		return [
35
+			'gridView' => GridView::class,
36
+		];
37
+	}
38 38
 
39
-    public abstract function render() : string;
39
+	public abstract function render() : string;
40 40
 }
41 41
\ No newline at end of file
Please login to merge, or discard this patch.
src/Renderers/DefaultRenderer.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,22 +7,22 @@
 block discarded – undo
7 7
 
8 8
 class DefaultRenderer extends BaseRenderer
9 9
 {
10
-    /**
11
-     * @return string
12
-     * @throws \Throwable
13
-     */
14
-    public function render(): string
15
-    {
16
-        $filters = [];
17
-        foreach ($this->gridView->columns as $column) {
18
-            if ($column->filter) {
19
-                $filters[$column->filter->name] = $this->gridView->getRequest()->getFilterValue($column->filter->name);
20
-            }
21
-        }
10
+	/**
11
+	 * @return string
12
+	 * @throws \Throwable
13
+	 */
14
+	public function render(): string
15
+	{
16
+		$filters = [];
17
+		foreach ($this->gridView->columns as $column) {
18
+			if ($column->filter) {
19
+				$filters[$column->filter->name] = $this->gridView->getRequest()->getFilterValue($column->filter->name);
20
+			}
21
+		}
22 22
 
23
-        return view('woo_gridview::renderers.default', [
24
-            'grid' => $this->gridView,
25
-            'filters' => $filters,
26
-        ])->render();
27
-    }
23
+		return view('woo_gridview::renderers.default', [
24
+			'grid' => $this->gridView,
25
+			'filters' => $filters,
26
+		])->render();
27
+	}
28 28
 }
29 29
\ No newline at end of file
Please login to merge, or discard this patch.
src/GridViewRequest.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -7,49 +7,49 @@
 block discarded – undo
7 7
 
8 8
 class GridViewRequest
9 9
 {
10
-    use Configurable;
11
-
12
-    public $page;
13
-
14
-    public $sortColumn;
15
-
16
-    public $sortOrder;
17
-
18
-    public $filters = [];
19
-
20
-    private function __construct($config)
21
-    {
22
-        $this->loadConfig($config);
23
-    }
24
-
25
-    /**
26
-     * Allows to parse request information and making request instance
27
-     * @param int $gridId
28
-     * @return GridViewRequest
29
-     */
30
-    public static function parse(int $gridId)
31
-    {
32
-        $request = Request::instance();
33
-
34
-        return new GridViewRequest([
35
-            'page' => (int)$request->input($gridId == 0 ? 'page' : 'grid.' . $gridId . '.page', 1),
36
-            'sortColumn' => $request->input($gridId == 0 ? 'sort' : 'grid.' . $gridId . '.sort'),
37
-            'sortOrder' => $request->input($gridId == 0 ? 'order' : 'grid.' . $gridId . '.order'),
38
-            'filters' => $request->input($gridId == 0 ? 'filters' : 'grid.' . $gridId . '.filters', []),
39
-        ]);
40
-    }
41
-
42
-    public function getFilterValue(string $name)
43
-    {
44
-        return $this->filters[$name] ?? '';
45
-    }
46
-
47
-    /**
48
-     * Should specify tests
49
-     * @return array
50
-     */
51
-    protected function configTests(): array
52
-    {
53
-        return [];
54
-    }
10
+	use Configurable;
11
+
12
+	public $page;
13
+
14
+	public $sortColumn;
15
+
16
+	public $sortOrder;
17
+
18
+	public $filters = [];
19
+
20
+	private function __construct($config)
21
+	{
22
+		$this->loadConfig($config);
23
+	}
24
+
25
+	/**
26
+	 * Allows to parse request information and making request instance
27
+	 * @param int $gridId
28
+	 * @return GridViewRequest
29
+	 */
30
+	public static function parse(int $gridId)
31
+	{
32
+		$request = Request::instance();
33
+
34
+		return new GridViewRequest([
35
+			'page' => (int)$request->input($gridId == 0 ? 'page' : 'grid.' . $gridId . '.page', 1),
36
+			'sortColumn' => $request->input($gridId == 0 ? 'sort' : 'grid.' . $gridId . '.sort'),
37
+			'sortOrder' => $request->input($gridId == 0 ? 'order' : 'grid.' . $gridId . '.order'),
38
+			'filters' => $request->input($gridId == 0 ? 'filters' : 'grid.' . $gridId . '.filters', []),
39
+		]);
40
+	}
41
+
42
+	public function getFilterValue(string $name)
43
+	{
44
+		return $this->filters[$name] ?? '';
45
+	}
46
+
47
+	/**
48
+	 * Should specify tests
49
+	 * @return array
50
+	 */
51
+	protected function configTests(): array
52
+	{
53
+		return [];
54
+	}
55 55
 }
56 56
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
         $request = Request::instance();
33 33
 
34 34
         return new GridViewRequest([
35
-            'page' => (int)$request->input($gridId == 0 ? 'page' : 'grid.' . $gridId . '.page', 1),
35
+            'page' => (int) $request->input($gridId == 0 ? 'page' : 'grid.' . $gridId . '.page', 1),
36 36
             'sortColumn' => $request->input($gridId == 0 ? 'sort' : 'grid.' . $gridId . '.sort'),
37 37
             'sortOrder' => $request->input($gridId == 0 ? 'order' : 'grid.' . $gridId . '.order'),
38 38
             'filters' => $request->input($gridId == 0 ? 'filters' : 'grid.' . $gridId . '.filters', []),
Please login to merge, or discard this patch.
src/Traits/Configurable.php 1 patch
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -7,88 +7,88 @@
 block discarded – undo
7 7
 
8 8
 trait Configurable
9 9
 {
10
-    /**
11
-     * Allows to load config into object properties
12
-     * @param array $config
13
-     * @throws GridViewConfigException
14
-     */
15
-    public function loadConfig(array $config)
16
-    {
17
-        foreach ($config as $key => $value) {
18
-
19
-            if (property_exists($this, $key)) {
20
-                $this->$key = $value;
21
-            }
22
-        }
23
-
24
-        $this->testConfig();
25
-    }
26
-
27
-    /**
28
-     * Should specify tests
29
-     * @return array
30
-     */
31
-    abstract protected function configTests() : array;
32
-
33
-    /**
34
-     * Allows to test attributes and types in config
35
-     * @throws GridViewConfigException
36
-     */
37
-    protected function testConfig()
38
-    {
39
-        foreach ($this->configTests() as $property => $tests) {
40
-
41
-            if (!property_exists($this, $property)) {
42
-                throw new GridViewConfigException(
43
-                    'Unable to test ' . get_class($this) . ': property ' . $property . ' does not exist'
44
-                );
45
-            }
46
-
47
-            $testPassed = true;
48
-            $testMessage = 'Validation failed';
49
-
50
-            foreach (explode('|', $tests) as $test) {
51
-
52
-                switch ($test) {
53
-                    case 'int':
54
-                        $testPassed = is_numeric($this->$property);
55
-                        $testMessage = 'Property should be numeric';
56
-                        break;
57
-
58
-                    case 'string':
59
-                        $testPassed = is_string($this->$property);
60
-                        $testMessage = 'Property should be a string';
61
-                        break;
62
-
63
-                    case 'array':
64
-                        $testPassed = is_array($this->$property);
65
-                        $testMessage = 'Property should be an array';
66
-                        break;
67
-
68
-                    case 'closure':
69
-                        $testPassed = $this->$property instanceof Closure;
70
-                        $testMessage = 'Property should be a valid callback (Closure instance)';
71
-                        break;
72
-
73
-                    case 'boolean':
74
-                        $testPassed = is_bool($this->$property);
75
-                        $testMessage = 'Property should be boolean';
76
-                        break;
77
-
78
-                    case 'any':
79
-                        break;
80
-
81
-                    default:
82
-                        $testPassed = $testPassed || is_a($this->$property, $test) || is_subclass_of($this->$property, $test);
83
-                        $testMessage = 'Property should be ' . $test . ' instance/class reference, got ' . print_r($this->$property, 1);
84
-                }
85
-            }
86
-
87
-            if (!$testPassed) {
88
-                throw new GridViewConfigException(
89
-                    'Tests ' . $tests . ' has failed on ' . get_class($this) . '::' . $property . ': ' . $testMessage
90
-                );
91
-            }
92
-        }
93
-    }
10
+	/**
11
+	 * Allows to load config into object properties
12
+	 * @param array $config
13
+	 * @throws GridViewConfigException
14
+	 */
15
+	public function loadConfig(array $config)
16
+	{
17
+		foreach ($config as $key => $value) {
18
+
19
+			if (property_exists($this, $key)) {
20
+				$this->$key = $value;
21
+			}
22
+		}
23
+
24
+		$this->testConfig();
25
+	}
26
+
27
+	/**
28
+	 * Should specify tests
29
+	 * @return array
30
+	 */
31
+	abstract protected function configTests() : array;
32
+
33
+	/**
34
+	 * Allows to test attributes and types in config
35
+	 * @throws GridViewConfigException
36
+	 */
37
+	protected function testConfig()
38
+	{
39
+		foreach ($this->configTests() as $property => $tests) {
40
+
41
+			if (!property_exists($this, $property)) {
42
+				throw new GridViewConfigException(
43
+					'Unable to test ' . get_class($this) . ': property ' . $property . ' does not exist'
44
+				);
45
+			}
46
+
47
+			$testPassed = true;
48
+			$testMessage = 'Validation failed';
49
+
50
+			foreach (explode('|', $tests) as $test) {
51
+
52
+				switch ($test) {
53
+					case 'int':
54
+						$testPassed = is_numeric($this->$property);
55
+						$testMessage = 'Property should be numeric';
56
+						break;
57
+
58
+					case 'string':
59
+						$testPassed = is_string($this->$property);
60
+						$testMessage = 'Property should be a string';
61
+						break;
62
+
63
+					case 'array':
64
+						$testPassed = is_array($this->$property);
65
+						$testMessage = 'Property should be an array';
66
+						break;
67
+
68
+					case 'closure':
69
+						$testPassed = $this->$property instanceof Closure;
70
+						$testMessage = 'Property should be a valid callback (Closure instance)';
71
+						break;
72
+
73
+					case 'boolean':
74
+						$testPassed = is_bool($this->$property);
75
+						$testMessage = 'Property should be boolean';
76
+						break;
77
+
78
+					case 'any':
79
+						break;
80
+
81
+					default:
82
+						$testPassed = $testPassed || is_a($this->$property, $test) || is_subclass_of($this->$property, $test);
83
+						$testMessage = 'Property should be ' . $test . ' instance/class reference, got ' . print_r($this->$property, 1);
84
+				}
85
+			}
86
+
87
+			if (!$testPassed) {
88
+				throw new GridViewConfigException(
89
+					'Tests ' . $tests . ' has failed on ' . get_class($this) . '::' . $property . ': ' . $testMessage
90
+				);
91
+			}
92
+		}
93
+	}
94 94
 }
95 95
\ No newline at end of file
Please login to merge, or discard this patch.
src/DataProviders/EloquentDataProvider.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -6,44 +6,44 @@
 block discarded – undo
6 6
 
7 7
 class EloquentDataProvider extends BaseDataProvider
8 8
 {
9
-    protected $query;
10
-
11
-    /**
12
-     * EloquentDataProvider constructor.
13
-     * @param Builder $query
14
-     */
15
-    public function __construct(Builder $query)
16
-    {
17
-        $this->query = clone $query;
18
-    }
19
-
20
-    /**
21
-     * @inheritdoc
22
-     */
23
-    public function getCount(): int
24
-    {
25
-        return $this->query->count();
26
-    }
27
-
28
-    /**
29
-     * @inheritdoc
30
-     */
31
-    public function getData(array $filters, string $orderBy, string $orderSort, int $page, int $perPage)
32
-    {
33
-        $query = clone $this->query;
34
-
35
-        foreach ($filters as $field => $value) {
36
-            $query->where($field, 'LIKE', '%' . $value . '%');
37
-        }
38
-
39
-        if ($orderBy) {
40
-            $query->orderBy($orderBy, $orderSort);
41
-        }
42
-
43
-        if ($perPage == 0) {
44
-            return $query->get();
45
-        }
46
-
47
-        return $query->offset(($page - 1) * $perPage)->limit($perPage)->get();
48
-    }
9
+	protected $query;
10
+
11
+	/**
12
+	 * EloquentDataProvider constructor.
13
+	 * @param Builder $query
14
+	 */
15
+	public function __construct(Builder $query)
16
+	{
17
+		$this->query = clone $query;
18
+	}
19
+
20
+	/**
21
+	 * @inheritdoc
22
+	 */
23
+	public function getCount(): int
24
+	{
25
+		return $this->query->count();
26
+	}
27
+
28
+	/**
29
+	 * @inheritdoc
30
+	 */
31
+	public function getData(array $filters, string $orderBy, string $orderSort, int $page, int $perPage)
32
+	{
33
+		$query = clone $this->query;
34
+
35
+		foreach ($filters as $field => $value) {
36
+			$query->where($field, 'LIKE', '%' . $value . '%');
37
+		}
38
+
39
+		if ($orderBy) {
40
+			$query->orderBy($orderBy, $orderSort);
41
+		}
42
+
43
+		if ($perPage == 0) {
44
+			return $query->get();
45
+		}
46
+
47
+		return $query->offset(($page - 1) * $perPage)->limit($perPage)->get();
48
+	}
49 49
 }
50 50
\ No newline at end of file
Please login to merge, or discard this patch.
src/DataProviders/BaseDataProvider.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -4,33 +4,33 @@
 block discarded – undo
4 4
 
5 5
 abstract class BaseDataProvider
6 6
 {
7
-    /**
8
-     * Should return total amount of rows
9
-     * @return int
10
-     */
11
-    abstract public function getCount() : int;
7
+	/**
8
+	 * Should return total amount of rows
9
+	 * @return int
10
+	 */
11
+	abstract public function getCount() : int;
12 12
 
13
-    /**
14
-     * Should return a list of data for current page
15
-     * @param array $filters
16
-     * @param string $orderBy
17
-     * @param string $orderSort
18
-     * @param int $page
19
-     * @param int $perPage - amount of records per page
20
-     * @return mixed
21
-     */
22
-    abstract public function getData(array $filters, string $orderBy, string $orderSort, int $page, int $perPage);
13
+	/**
14
+	 * Should return a list of data for current page
15
+	 * @param array $filters
16
+	 * @param string $orderBy
17
+	 * @param string $orderSort
18
+	 * @param int $page
19
+	 * @param int $perPage - amount of records per page
20
+	 * @return mixed
21
+	 */
22
+	abstract public function getData(array $filters, string $orderBy, string $orderSort, int $page, int $perPage);
23 23
 
24
-    /**
25
-     * Allows to get amount of found pages
26
-     */
27
-    public function getTotalPages(int $perPage): int
28
-    {
29
-        if ($perPage == 0) {
30
-            return 1;
31
-        }
24
+	/**
25
+	 * Allows to get amount of found pages
26
+	 */
27
+	public function getTotalPages(int $perPage): int
28
+	{
29
+		if ($perPage == 0) {
30
+			return 1;
31
+		}
32 32
 
33
-        return ceil($this->getCount() / $perPage);
34
-    }
33
+		return ceil($this->getCount() / $perPage);
34
+	}
35 35
 
36 36
 }
37 37
\ No newline at end of file
Please login to merge, or discard this patch.
src/DataProviders/ArrayDataProvider.php 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -4,30 +4,30 @@
 block discarded – undo
4 4
 
5 5
 class ArrayDataProvider extends BaseDataProvider
6 6
 {
7
-    /**
8
-     * @var array
9
-     */
10
-    private $data;
7
+	/**
8
+	 * @var array
9
+	 */
10
+	private $data;
11 11
 
12
-    public function __construct(array $data)
13
-    {
14
-        $this->data = $data;
15
-    }
12
+	public function __construct(array $data)
13
+	{
14
+		$this->data = $data;
15
+	}
16 16
 
17
-    /**
18
-     * Should return total amount of rows
19
-     * @return int
20
-     */
21
-    public function getCount() : int
22
-    {
23
-        return count($this->data);
24
-    }
17
+	/**
18
+	 * Should return total amount of rows
19
+	 * @return int
20
+	 */
21
+	public function getCount() : int
22
+	{
23
+		return count($this->data);
24
+	}
25 25
 
26
-    /**
27
-     * @inheritdoc
28
-     */
29
-    public function getData(array $filters, string $orderBy, string $orderSort, int $page, int $perPage)
30
-    {
31
-        return array_splice($this->data, ($page -1) * $perPage, $perPage);
32
-    }
26
+	/**
27
+	 * @inheritdoc
28
+	 */
29
+	public function getData(array $filters, string $orderBy, string $orderSort, int $page, int $perPage)
30
+	{
31
+		return array_splice($this->data, ($page -1) * $perPage, $perPage);
32
+	}
33 33
 }
34 34
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,6 +28,6 @@
 block discarded – undo
28 28
      */
29 29
     public function getData(array $filters, string $orderBy, string $orderSort, int $page, int $perPage)
30 30
     {
31
-        return array_splice($this->data, ($page -1) * $perPage, $perPage);
31
+        return array_splice($this->data, ($page - 1) * $perPage, $perPage);
32 32
     }
33 33
 }
34 34
\ No newline at end of file
Please login to merge, or discard this patch.