Completed
Push — master ( 33a6ff...051b00 )
by Denis
31s
created
src/Columns/Actions/DeleteAction.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 
5 5
 class DeleteAction extends Action
6 6
 {
7
-    public function __construct(string $url, string $content = '<i class="fa fa-trash-alt"></i>')
8
-    {
9
-        parent::__construct($url, $content, 'DELETE');
10
-    }
7
+	public function __construct(string $url, string $content = '<i class="fa fa-trash-alt"></i>')
8
+	{
9
+		parent::__construct($url, $content, 'DELETE');
10
+	}
11 11
 }
12 12
\ No newline at end of file
Please login to merge, or discard this patch.
src/Columns/Actions/Action.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -6,63 +6,63 @@
 block discarded – undo
6 6
 
7 7
 class Action
8 8
 {
9
-    /**
10
-     * @var string
11
-     */
12
-    protected $url;
9
+	/**
10
+	 * @var string
11
+	 */
12
+	protected $url;
13 13
 
14
-    /**
15
-     * @var string
16
-     */
17
-    protected $content;
14
+	/**
15
+	 * @var string
16
+	 */
17
+	protected $content;
18 18
 
19
-    /**
20
-     * @var string
21
-     */
22
-    protected $method;
19
+	/**
20
+	 * @var string
21
+	 */
22
+	protected $method;
23 23
 
24
-    /**
25
-     * Action constructor.
26
-     * @param string|Closure $url
27
-     * @param string $content
28
-     * @param string $method
29
-     */
30
-    public function __construct($url, string $content, string $method = 'GET')
31
-    {
32
-        $this->url = $url;
24
+	/**
25
+	 * Action constructor.
26
+	 * @param string|Closure $url
27
+	 * @param string $content
28
+	 * @param string $method
29
+	 */
30
+	public function __construct($url, string $content, string $method = 'GET')
31
+	{
32
+		$this->url = $url;
33 33
 
34
-        $this->content = $content;
34
+		$this->content = $content;
35 35
 
36
-        $this->method = $method;
37
-    }
36
+		$this->method = $method;
37
+	}
38 38
 
39
-    protected function buildUrl($row)
40
-    {
41
-        if ($this->url instanceof Closure) {
42
-            return call_user_func($this->url, $row);
43
-        }
39
+	protected function buildUrl($row)
40
+	{
41
+		if ($this->url instanceof Closure) {
42
+			return call_user_func($this->url, $row);
43
+		}
44 44
 
45
-        return preg_replace_callback('/\{([\w\_]+)\}/', function($match) use ($row) {
45
+		return preg_replace_callback('/\{([\w\_]+)\}/', function($match) use ($row) {
46 46
 
47
-            $match = $match[1];
47
+			$match = $match[1];
48 48
 
49
-            if (isset($row->$match)) {
50
-                return $row->$match;
49
+			if (isset($row->$match)) {
50
+				return $row->$match;
51 51
 
52
-            } elseif (isset($row[$match])) {
53
-                return $row[$match];
54
-            }
52
+			} elseif (isset($row[$match])) {
53
+				return $row[$match];
54
+			}
55 55
 
56
-            return '';
57
-        }, $this->url);
58
-    }
56
+			return '';
57
+		}, $this->url);
58
+	}
59 59
 
60
-    public function render($row)
61
-    {
62
-        return view('woo_gridview::columns.action', [
63
-            'url' => $this->buildUrl($row),
64
-            'content' => $this->content,
65
-            'method' => $this->method,
66
-        ])->render();
67
-    }
60
+	public function render($row)
61
+	{
62
+		return view('woo_gridview::columns.action', [
63
+			'url' => $this->buildUrl($row),
64
+			'content' => $this->content,
65
+			'method' => $this->method,
66
+		])->render();
67
+	}
68 68
 }
69 69
\ No newline at end of file
Please login to merge, or discard this patch.
src/Columns/Actions/ShowAction.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@
 block discarded – undo
6 6
 
7 7
 class ShowAction extends Action
8 8
 {
9
-    public function __construct(string $url, string $content = '<i class="fa fa-eye"></i>')
10
-    {
11
-        parent::__construct($url, $content, 'GET');
12
-    }
9
+	public function __construct(string $url, string $content = '<i class="fa fa-eye"></i>')
10
+	{
11
+		parent::__construct($url, $content, 'GET');
12
+	}
13 13
 }
14 14
\ No newline at end of file
Please login to merge, or discard this patch.
src/Columns/Actions/EditAction.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@
 block discarded – undo
6 6
 
7 7
 class EditAction extends Action
8 8
 {
9
-    public function __construct(string $url, string $content = '<i class="fa fa-edit"></i>')
10
-    {
11
-        parent::__construct($url,  $content, 'GET');
12
-    }
9
+	public function __construct(string $url, string $content = '<i class="fa fa-edit"></i>')
10
+	{
11
+		parent::__construct($url,  $content, 'GET');
12
+	}
13 13
 }
14 14
\ 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
@@ -8,6 +8,6 @@
 block discarded – undo
8 8
 {
9 9
     public function __construct(string $url, string $content = '<i class="fa fa-edit"></i>')
10 10
     {
11
-        parent::__construct($url,  $content, 'GET');
11
+        parent::__construct($url, $content, 'GET');
12 12
     }
13 13
 }
14 14
\ No newline at end of file
Please login to merge, or discard this patch.
src/GridViewRequest.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -7,77 +7,77 @@
 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 $perPage;
19
-
20
-    public $filters = [];
21
-
22
-    private function __construct($config)
23
-    {
24
-        $this->loadConfig($config);
25
-    }
26
-
27
-    private static function gridField(int $gridId, string $field)
28
-    {
29
-        return $gridId == 0 ? $field : 'grid.' . $gridId . '.' . $field;
30
-    }
31
-
32
-    /**
33
-     * Allows to parse request information and making request instance
34
-     * @param int $gridId
35
-     * @return GridViewRequest
36
-     */
37
-    public static function parse(int $gridId)
38
-    {
39
-        $request = Request::instance();
40
-
41
-        $page = $request->input(self::gridField($gridId, 'page'), 1);
42
-        $sortColumn = $request->input(self::gridField($gridId, 'sort'), '');
43
-        $sortOrder = $request->input(self::gridField($gridId, 'order'), 'DESC');
44
-        $filters = $request->input(self::gridField($gridId, 'filters'), []);
45
-
46
-        if ($page <= 0) {
47
-            $page = 1;
48
-        }
49
-
50
-        if (!is_string($sortColumn)) {
51
-            $sortColumn = '';
52
-        }
53
-
54
-        if (!in_array($sortOrder, ['ASC', 'DESC'])) {
55
-            $sortOrder = 'DESC';
56
-        }
57
-
58
-        if (!is_array($filters)) {
59
-            $filters = [];
60
-        }
61
-
62
-        return new GridViewRequest([
63
-            'page' => $page,
64
-            'sortColumn' => $sortColumn,
65
-            'sortOrder' => $sortOrder,
66
-            'filters' => $filters,
67
-        ]);
68
-    }
69
-
70
-    public function getFilterValue(string $name)
71
-    {
72
-        return $this->filters[$name] ?? '';
73
-    }
74
-
75
-    /**
76
-     * Should specify tests
77
-     * @return array
78
-     */
79
-    protected function configTests(): array
80
-    {
81
-        return [];
82
-    }
10
+	use Configurable;
11
+
12
+	public $page;
13
+
14
+	public $sortColumn;
15
+
16
+	public $sortOrder;
17
+
18
+	public $perPage;
19
+
20
+	public $filters = [];
21
+
22
+	private function __construct($config)
23
+	{
24
+		$this->loadConfig($config);
25
+	}
26
+
27
+	private static function gridField(int $gridId, string $field)
28
+	{
29
+		return $gridId == 0 ? $field : 'grid.' . $gridId . '.' . $field;
30
+	}
31
+
32
+	/**
33
+	 * Allows to parse request information and making request instance
34
+	 * @param int $gridId
35
+	 * @return GridViewRequest
36
+	 */
37
+	public static function parse(int $gridId)
38
+	{
39
+		$request = Request::instance();
40
+
41
+		$page = $request->input(self::gridField($gridId, 'page'), 1);
42
+		$sortColumn = $request->input(self::gridField($gridId, 'sort'), '');
43
+		$sortOrder = $request->input(self::gridField($gridId, 'order'), 'DESC');
44
+		$filters = $request->input(self::gridField($gridId, 'filters'), []);
45
+
46
+		if ($page <= 0) {
47
+			$page = 1;
48
+		}
49
+
50
+		if (!is_string($sortColumn)) {
51
+			$sortColumn = '';
52
+		}
53
+
54
+		if (!in_array($sortOrder, ['ASC', 'DESC'])) {
55
+			$sortOrder = 'DESC';
56
+		}
57
+
58
+		if (!is_array($filters)) {
59
+			$filters = [];
60
+		}
61
+
62
+		return new GridViewRequest([
63
+			'page' => $page,
64
+			'sortColumn' => $sortColumn,
65
+			'sortOrder' => $sortOrder,
66
+			'filters' => $filters,
67
+		]);
68
+	}
69
+
70
+	public function getFilterValue(string $name)
71
+	{
72
+		return $this->filters[$name] ?? '';
73
+	}
74
+
75
+	/**
76
+	 * Should specify tests
77
+	 * @return array
78
+	 */
79
+	protected function configTests(): array
80
+	{
81
+		return [];
82
+	}
83 83
 }
84 84
\ No newline at end of file
Please login to merge, or discard this patch.
src/DataProviders/ArrayDataProvider.php 2 patches
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -6,74 +6,74 @@
 block discarded – undo
6 6
 
7 7
 class ArrayDataProvider extends BaseDataProvider
8 8
 {
9
-    /**
10
-     * @var array
11
-     */
12
-    private $data;
9
+	/**
10
+	 * @var array
11
+	 */
12
+	private $data;
13 13
 
14
-    public function __construct(array $data)
15
-    {
16
-        $this->data = $data;
17
-    }
14
+	public function __construct(array $data)
15
+	{
16
+		$this->data = $data;
17
+	}
18 18
 
19
-    /**
20
-     * @param GridViewRequest $request
21
-     * @return array
22
-     */
23
-    protected function processData(GridViewRequest $request) : array
24
-    {
25
-        if (empty($this->data)) {
26
-            return [];
27
-        }
19
+	/**
20
+	 * @param GridViewRequest $request
21
+	 * @return array
22
+	 */
23
+	protected function processData(GridViewRequest $request) : array
24
+	{
25
+		if (empty($this->data)) {
26
+			return [];
27
+		}
28 28
 
29
-        $tmp = collect($this->data);
29
+		$tmp = collect($this->data);
30 30
 
31
-        if (!empty($request->filters)) {
32
-            $tmp = $tmp->filter(function($item) use ($request) {
33
-                foreach ($request->filters as $filterKey => $filterValue) {
31
+		if (!empty($request->filters)) {
32
+			$tmp = $tmp->filter(function($item) use ($request) {
33
+				foreach ($request->filters as $filterKey => $filterValue) {
34 34
 
35
-                    if (!isset($item[$filterKey])) {
36
-                        return false;
37
-                    }
35
+					if (!isset($item[$filterKey])) {
36
+						return false;
37
+					}
38 38
 
39
-                    if (strpos($item[$filterKey], $filterValue) === false) {
40
-                        return false;
41
-                    }
42
-                }
39
+					if (strpos($item[$filterKey], $filterValue) === false) {
40
+						return false;
41
+					}
42
+				}
43 43
 
44
-                return true;
45
-            });
46
-        }
44
+				return true;
45
+			});
46
+		}
47 47
 
48
-        if (!empty($request->sortColumn)) {
49
-            $tmp = $tmp->sortBy(
50
-                $request->sortColumn,
51
-                SORT_REGULAR,
52
-                $request->sortOrder == 'DESC'
53
-            );
54
-        }
48
+		if (!empty($request->sortColumn)) {
49
+			$tmp = $tmp->sortBy(
50
+				$request->sortColumn,
51
+				SORT_REGULAR,
52
+				$request->sortOrder == 'DESC'
53
+			);
54
+		}
55 55
 
56
-        return $tmp->values()->all();
57
-    }
56
+		return $tmp->values()->all();
57
+	}
58 58
 
59
-    /**
60
-     * @inheritdoc
61
-     */
62
-    public function getCount(GridViewRequest $request) : int
63
-    {
64
-        return count($this->processData($request));
65
-    }
59
+	/**
60
+	 * @inheritdoc
61
+	 */
62
+	public function getCount(GridViewRequest $request) : int
63
+	{
64
+		return count($this->processData($request));
65
+	}
66 66
 
67
-    /**
68
-     * @inheritdoc
69
-     */
70
-    public function getData(GridViewRequest $request)
71
-    {
72
-        $tmp = $this->processData($request);
67
+	/**
68
+	 * @inheritdoc
69
+	 */
70
+	public function getData(GridViewRequest $request)
71
+	{
72
+		$tmp = $this->processData($request);
73 73
 
74
-        return array_splice(
75
-            $tmp,
76
-            ($request->page -1) * $request->perPage, $request->perPage
77
-        );
78
-    }
74
+		return array_splice(
75
+			$tmp,
76
+			($request->page -1) * $request->perPage, $request->perPage
77
+		);
78
+	}
79 79
 }
80 80
\ 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
@@ -73,7 +73,7 @@
 block discarded – undo
73 73
 
74 74
         return array_splice(
75 75
             $tmp,
76
-            ($request->page -1) * $request->perPage, $request->perPage
76
+            ($request->page - 1) * $request->perPage, $request->perPage
77 77
         );
78 78
     }
79 79
 }
80 80
\ No newline at end of file
Please login to merge, or discard this patch.
src/GridViewServiceProvider.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 
20 20
 		require_once __DIR__ . '/functions.php';
21 21
 
22
-        \Blade::directive('grid', function ($expression) {
22
+        \Blade::directive('grid', function($expression) {
23 23
             return "<?php echo grid($expression) ?>";
24 24
         });
25 25
 
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -19,17 +19,17 @@
 block discarded – undo
19 19
 
20 20
 		require_once __DIR__ . '/functions.php';
21 21
 
22
-        \Blade::directive('grid', function ($expression) {
23
-            return "<?php echo grid($expression) ?>";
24
-        });
22
+		\Blade::directive('grid', function ($expression) {
23
+			return "<?php echo grid($expression) ?>";
24
+		});
25 25
 
26
-        $this->publishes([
27
-            __DIR__ . '/../public' => 'public/vendor/grid-view',
28
-        ], 'public');
26
+		$this->publishes([
27
+			__DIR__ . '/../public' => 'public/vendor/grid-view',
28
+		], 'public');
29 29
 
30
-        if (!File::isDirectory(public_path('vendor/grid-view'))) {
31
-            Artisan::call('vendor:publish', ['--tag' => 'public', '--force' => '']);
32
-        }
30
+		if (!File::isDirectory(public_path('vendor/grid-view'))) {
31
+			Artisan::call('vendor:publish', ['--tag' => 'public', '--force' => '']);
32
+		}
33 33
 	}
34 34
 
35 35
 	public function register()
Please login to merge, or discard this patch.
src/functions.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,5 +7,5 @@
 block discarded – undo
7 7
  * @throws \Woo\GridView\Exceptions\GridViewConfigException
8 8
  */
9 9
 function grid(array $config) {
10
-    return (new \Woo\GridView\GridView($config))->render();
10
+	return (new \Woo\GridView\GridView($config))->render();
11 11
 }
12 12
\ No newline at end of file
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, check ' . $property;
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, check ' . $property;
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.