Completed
Push — master ( 044d29...dcce97 )
by Denis
106:13 queued 67:58
created
src/functions.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,5 +6,5 @@
 block discarded – undo
6 6
  * @return \Woo\GridView\GridView
7 7
  */
8 8
 function grid(array $config) {
9
-    return \Woo\GridView\GridView::make($config);
9
+	return \Woo\GridView\GridView::make($config);
10 10
 }
11 11
\ No newline at end of file
Please login to merge, or discard this patch.
src/GridViewHelper.php 1 patch
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -6,94 +6,94 @@
 block discarded – undo
6 6
 
7 7
 class GridViewHelper
8 8
 {
9
-    private function __construct() {}
10
-
11
-    /**
12
-     * Allows to load config into object properties
13
-     * @param object $object
14
-     * @param array $config
15
-     * @throws GridViewConfigException
16
-     */
17
-    public static function loadConfig($object, array $config)
18
-    {
19
-        foreach ($config as $key => $value) {
20
-
21
-            if (property_exists($object, $key)) {
22
-                $object->$key = $value;
23
-            }
24
-        }
25
-    }
26
-
27
-    /**
28
-     * Allows to test attributes and types in config
29
-     * @param $object
30
-     * @param array $tests
31
-     * @throws GridViewConfigException
32
-     */
33
-    public static function testConfig($object, array $tests)
34
-    {
35
-        foreach ($tests as $property => $test) {
36
-
37
-            if (!property_exists($object, $property)) {
38
-                throw new GridViewConfigException(
39
-                    'Unable to test ' . get_class($object) . ': property ' . $property . ' does not exist'
40
-                );
41
-            }
42
-
43
-            if (is_scalar($test)) {
44
-
45
-                $testPassed = true;
46
-
47
-                switch ($test) {
48
-                    case 'int':
49
-                        $testPassed = is_numeric($object->$property);
50
-                        break;
51
-
52
-                    case 'string':
53
-                        $testPassed = is_string($object->$property);
54
-                        break;
55
-
56
-                    case 'array':
57
-                        $testPassed = is_array($object->$property);
58
-                        break;
59
-
60
-                    case 'closure':
61
-                        $testPassed = $object->$property instanceof \Closure;
62
-                        break;
63
-
64
-                    case 'any':
65
-                        break;
66
-
67
-                    default:
68
-                        $testPassed = is_subclass_of($object->$property, $test);
69
-                }
70
-
71
-                if (!$testPassed) {
72
-                    throw new GridViewConfigException('
9
+	private function __construct() {}
10
+
11
+	/**
12
+	 * Allows to load config into object properties
13
+	 * @param object $object
14
+	 * @param array $config
15
+	 * @throws GridViewConfigException
16
+	 */
17
+	public static function loadConfig($object, array $config)
18
+	{
19
+		foreach ($config as $key => $value) {
20
+
21
+			if (property_exists($object, $key)) {
22
+				$object->$key = $value;
23
+			}
24
+		}
25
+	}
26
+
27
+	/**
28
+	 * Allows to test attributes and types in config
29
+	 * @param $object
30
+	 * @param array $tests
31
+	 * @throws GridViewConfigException
32
+	 */
33
+	public static function testConfig($object, array $tests)
34
+	{
35
+		foreach ($tests as $property => $test) {
36
+
37
+			if (!property_exists($object, $property)) {
38
+				throw new GridViewConfigException(
39
+					'Unable to test ' . get_class($object) . ': property ' . $property . ' does not exist'
40
+				);
41
+			}
42
+
43
+			if (is_scalar($test)) {
44
+
45
+				$testPassed = true;
46
+
47
+				switch ($test) {
48
+					case 'int':
49
+						$testPassed = is_numeric($object->$property);
50
+						break;
51
+
52
+					case 'string':
53
+						$testPassed = is_string($object->$property);
54
+						break;
55
+
56
+					case 'array':
57
+						$testPassed = is_array($object->$property);
58
+						break;
59
+
60
+					case 'closure':
61
+						$testPassed = $object->$property instanceof \Closure;
62
+						break;
63
+
64
+					case 'any':
65
+						break;
66
+
67
+					default:
68
+						$testPassed = is_subclass_of($object->$property, $test);
69
+				}
70
+
71
+				if (!$testPassed) {
72
+					throw new GridViewConfigException('
73 73
                         Test ' . $test . ' has failed on ' . get_class($object) . '::' . $property
74
-                    );
75
-                }
76
-            }
77
-        }
78
-    }
79
-
80
-    /**
81
-     * Allows to convert options array to html string
82
-     * @param array $htmlOptions
83
-     * @return string
84
-     */
85
-    public static function htmlOptionsToString(array $htmlOptions) : string
86
-    {
87
-        if (empty($htmlOptions)) {
88
-            return '';
89
-        }
90
-
91
-        $out = [];
92
-
93
-        foreach ($htmlOptions as $k => $v) {
94
-            $out[] = htmlentities($k) . '="' . htmlentities($v, ENT_COMPAT) . '"';
95
-        }
96
-
97
-        return implode(' ', $out);
98
-    }
74
+					);
75
+				}
76
+			}
77
+		}
78
+	}
79
+
80
+	/**
81
+	 * Allows to convert options array to html string
82
+	 * @param array $htmlOptions
83
+	 * @return string
84
+	 */
85
+	public static function htmlOptionsToString(array $htmlOptions) : string
86
+	{
87
+		if (empty($htmlOptions)) {
88
+			return '';
89
+		}
90
+
91
+		$out = [];
92
+
93
+		foreach ($htmlOptions as $k => $v) {
94
+			$out[] = htmlentities($k) . '="' . htmlentities($v, ENT_COMPAT) . '"';
95
+		}
96
+
97
+		return implode(' ', $out);
98
+	}
99 99
 }
100 100
\ No newline at end of file
Please login to merge, or discard this patch.
src/Renderers/DefaultRenderer.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -7,20 +7,20 @@
 block discarded – undo
7 7
 
8 8
 class DefaultRenderer implements RendererInterface
9 9
 {
10
-    /**
11
-     * @inheritdoc
12
-     */
13
-    public function render(GridView $view): string
14
-    {
15
-        $page = intval($_GET['page'] ?? 1);
10
+	/**
11
+	 * @inheritdoc
12
+	 */
13
+	public function render(GridView $view): string
14
+	{
15
+		$page = intval($_GET['page'] ?? 1);
16 16
 
17
-        return view('woo_gridview::render-default', [
18
-            'columns' => $view->columns,
19
-            'data' => $view->dataProvider->getData($page, $view->rowsPerPage),
20
-            'tableHtmlOptions' => GridViewHelper::htmlOptionsToString($view->tableHtmlOptions),
21
-            'dataProvider' => $view->dataProvider,
22
-            'perPage' => $view->rowsPerPage,
23
-            'currentPage' => $page,
24
-        ])->render();
25
-    }
17
+		return view('woo_gridview::render-default', [
18
+			'columns' => $view->columns,
19
+			'data' => $view->dataProvider->getData($page, $view->rowsPerPage),
20
+			'tableHtmlOptions' => GridViewHelper::htmlOptionsToString($view->tableHtmlOptions),
21
+			'dataProvider' => $view->dataProvider,
22
+			'perPage' => $view->rowsPerPage,
23
+			'currentPage' => $page,
24
+		])->render();
25
+	}
26 26
 }
27 27
\ No newline at end of file
Please login to merge, or discard this patch.
src/Renderers/RendererInterface.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,5 +6,5 @@
 block discarded – undo
6 6
 
7 7
 interface RendererInterface
8 8
 {
9
-    public function render(GridView $view) : string;
9
+	public function render(GridView $view) : string;
10 10
 }
11 11
\ No newline at end of file
Please login to merge, or discard this patch.
src/Columns/BaseColumn.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -6,48 +6,48 @@
 block discarded – undo
6 6
 
7 7
 abstract class BaseColumn
8 8
 {
9
-    public $title = '';
10
-
11
-    public $value = '';
12
-
13
-    public $headerHtmlOptions = [];
14
-
15
-    public $contentHtmlOptions = [];
16
-
17
-    public function __construct(array $config)
18
-    {
19
-        GridViewHelper::loadConfig($this, $config);
20
-
21
-        GridViewHelper::testConfig($this, [
22
-            'title' => 'string',
23
-            'value' => 'any',
24
-            'headerHtmlOptions' => 'array',
25
-            'contentHtmlOptions' => 'array',
26
-        ]);
27
-    }
28
-
29
-    /**
30
-     * Formatted header html options
31
-     * @return string
32
-     */
33
-    public function headerHtmlOptions() : string
34
-    {
35
-        return GridViewHelper::htmlOptionsToString($this->headerHtmlOptions);
36
-    }
37
-
38
-    /**
39
-     * Formatted content html options
40
-     * @return string
41
-     */
42
-    public function contentHtmlOptions() : string
43
-    {
44
-        return GridViewHelper::htmlOptionsToString($this->contentHtmlOptions);
45
-    }
46
-
47
-    /**
48
-     * Render column value for row
49
-     * @param array|object $row
50
-     * @return string|mixed
51
-     */
52
-    public abstract function renderValue($row);
9
+	public $title = '';
10
+
11
+	public $value = '';
12
+
13
+	public $headerHtmlOptions = [];
14
+
15
+	public $contentHtmlOptions = [];
16
+
17
+	public function __construct(array $config)
18
+	{
19
+		GridViewHelper::loadConfig($this, $config);
20
+
21
+		GridViewHelper::testConfig($this, [
22
+			'title' => 'string',
23
+			'value' => 'any',
24
+			'headerHtmlOptions' => 'array',
25
+			'contentHtmlOptions' => 'array',
26
+		]);
27
+	}
28
+
29
+	/**
30
+	 * Formatted header html options
31
+	 * @return string
32
+	 */
33
+	public function headerHtmlOptions() : string
34
+	{
35
+		return GridViewHelper::htmlOptionsToString($this->headerHtmlOptions);
36
+	}
37
+
38
+	/**
39
+	 * Formatted content html options
40
+	 * @return string
41
+	 */
42
+	public function contentHtmlOptions() : string
43
+	{
44
+		return GridViewHelper::htmlOptionsToString($this->contentHtmlOptions);
45
+	}
46
+
47
+	/**
48
+	 * Render column value for row
49
+	 * @param array|object $row
50
+	 * @return string|mixed
51
+	 */
52
+	public abstract function renderValue($row);
53 53
 }
54 54
\ No newline at end of file
Please login to merge, or discard this patch.
src/Columns/RawColumn.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -6,24 +6,24 @@
 block discarded – undo
6 6
 
7 7
 class RawColumn extends BaseColumn
8 8
 {
9
-    /**
10
-     * RawColumn constructor.
11
-     * @param array $config
12
-     */
13
-    public function __construct(array $config)
14
-    {
15
-        parent::__construct($config);
9
+	/**
10
+	 * RawColumn constructor.
11
+	 * @param array $config
12
+	 */
13
+	public function __construct(array $config)
14
+	{
15
+		parent::__construct($config);
16 16
 
17
-        GridViewHelper::testConfig($this, [
18
-            'value' => 'closure',
19
-        ]);
20
-    }
17
+		GridViewHelper::testConfig($this, [
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/DataProviders/DataProviderInterface.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -4,24 +4,24 @@
 block discarded – undo
4 4
 
5 5
 interface DataProviderInterface
6 6
 {
7
-    /**
8
-     * Should return total amount of rows
9
-     * @return int
10
-     */
11
-    public function getCount() : int;
7
+	/**
8
+	 * Should return total amount of rows
9
+	 * @return int
10
+	 */
11
+	public function getCount() : int;
12 12
 
13
-    /**
14
-     * Should return amount of pages
15
-     * @param int $perPage - amount of records per page
16
-     * @return int
17
-     */
18
-    public function getTotalPages(int $perPage) : int;
13
+	/**
14
+	 * Should return amount of pages
15
+	 * @param int $perPage - amount of records per page
16
+	 * @return int
17
+	 */
18
+	public function getTotalPages(int $perPage) : int;
19 19
 
20
-    /**
21
-     * Should return a list of data for current page
22
-     * @param int $page
23
-     * @param int $perPage - amount of records per page
24
-     * @return mixed
25
-     */
26
-    public function getData(int $page, int $perPage);
20
+	/**
21
+	 * Should return a list of data for current page
22
+	 * @param int $page
23
+	 * @param int $perPage - amount of records per page
24
+	 * @return mixed
25
+	 */
26
+	public function getData(int $page, int $perPage);
27 27
 }
28 28
\ No newline at end of file
Please login to merge, or discard this patch.
src/DataProviders/EloquentDataProvider.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -6,38 +6,38 @@
 block discarded – undo
6 6
 
7 7
 class EloquentDataProvider implements DataProviderInterface
8 8
 {
9
-    protected $query;
9
+	protected $query;
10 10
 
11
-    /**
12
-     * EloquentDataProvider constructor.
13
-     * @param Builder $query
14
-     */
15
-    public function __construct(Builder $query)
16
-    {
17
-        $this->query = $query;
18
-    }
11
+	/**
12
+	 * EloquentDataProvider constructor.
13
+	 * @param Builder $query
14
+	 */
15
+	public function __construct(Builder $query)
16
+	{
17
+		$this->query = $query;
18
+	}
19 19
 
20
-    /**
21
-     * @inheritdoc
22
-     */
23
-    public function getCount(): int
24
-    {
25
-        return $this->query->count();
26
-    }
20
+	/**
21
+	 * @inheritdoc
22
+	 */
23
+	public function getCount(): int
24
+	{
25
+		return $this->query->count();
26
+	}
27 27
 
28
-    /**
29
-     * @inheritdoc
30
-     */
31
-    public function getTotalPages(int $perPage): int
32
-    {
33
-        return ceil($this->getCount() / $perPage);
34
-    }
28
+	/**
29
+	 * @inheritdoc
30
+	 */
31
+	public function getTotalPages(int $perPage): int
32
+	{
33
+		return ceil($this->getCount() / $perPage);
34
+	}
35 35
 
36
-    /**
37
-     * @inheritdoc
38
-     */
39
-    public function getData(int $page, int $perPage)
40
-    {
41
-        return (clone $this->query)->paginate($perPage, ['*'], 'page', $page);
42
-    }
36
+	/**
37
+	 * @inheritdoc
38
+	 */
39
+	public function getData(int $page, int $perPage)
40
+	{
41
+		return (clone $this->query)->paginate($perPage, ['*'], 'page', $page);
42
+	}
43 43
 }
44 44
\ No newline at end of file
Please login to merge, or discard this patch.
src/GridViewServiceProvider.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
 	 */
14 14
 	public function boot()
15 15
 	{
16
-		$this->loadViewsFrom(__DIR__.'/../views', 'woo_gridview');
16
+		$this->loadViewsFrom(__DIR__ . '/../views', 'woo_gridview');
17 17
 
18 18
 		require_once __DIR__ . '/functions.php';
19 19
 	}
Please login to merge, or discard this patch.