Test Failed
Push — tmp ( 15f615...89cc97 )
by Paul
10:31 queued 04:40
created
plugin/Blocks/SiteReviewsFormBlock.php 1 patch
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -7,113 +7,113 @@
 block discarded – undo
7 7
 
8 8
 class SiteReviewsFormBlock extends BlockGenerator
9 9
 {
10
-    /**
11
-     * @return array
12
-     */
13
-    public function attributes()
14
-    {
15
-        return [
16
-            'assign_to' => [
17
-                'default' => '',
18
-                'type' => 'string',
19
-            ],
20
-            'assign_to_custom' => [
21
-                'default' => '',
22
-                'type' => 'string',
23
-            ],
24
-            'category' => [
25
-                'default' => '',
26
-                'type' => 'string',
27
-            ],
28
-            'className' => [
29
-                'default' => '',
30
-                'type' => 'string',
31
-            ],
32
-            'hide' => [
33
-                'default' => '',
34
-                'type' => 'string',
35
-            ],
36
-            'id' => [
37
-                'default' => '',
38
-                'type' => 'string',
39
-            ],
40
-            'user' => [
41
-                'default' => '',
42
-                'type' => 'string',
43
-            ],
44
-        ];
45
-    }
10
+	/**
11
+	 * @return array
12
+	 */
13
+	public function attributes()
14
+	{
15
+		return [
16
+			'assign_to' => [
17
+				'default' => '',
18
+				'type' => 'string',
19
+			],
20
+			'assign_to_custom' => [
21
+				'default' => '',
22
+				'type' => 'string',
23
+			],
24
+			'category' => [
25
+				'default' => '',
26
+				'type' => 'string',
27
+			],
28
+			'className' => [
29
+				'default' => '',
30
+				'type' => 'string',
31
+			],
32
+			'hide' => [
33
+				'default' => '',
34
+				'type' => 'string',
35
+			],
36
+			'id' => [
37
+				'default' => '',
38
+				'type' => 'string',
39
+			],
40
+			'user' => [
41
+				'default' => '',
42
+				'type' => 'string',
43
+			],
44
+		];
45
+	}
46 46
 
47
-    /**
48
-     * @return string
49
-     */
50
-    public function render(array $attributes)
51
-    {
52
-        $attributes['class'] = $attributes['className'];
53
-        $shortcode = glsr(Shortcode::class);
54
-        if ('edit' == filter_input(INPUT_GET, 'context')) {
55
-            $this->filterBlockClass();
56
-            $this->filterFormFields();
57
-            $this->filterRatingField();
58
-            $this->filterSubmitButton();
59
-            if (!$this->hasVisibleFields($shortcode, $attributes)) {
60
-                $this->filterInterpolation();
61
-            }
62
-        }
63
-        return $shortcode->buildBlock($attributes);
64
-    }
47
+	/**
48
+	 * @return string
49
+	 */
50
+	public function render(array $attributes)
51
+	{
52
+		$attributes['class'] = $attributes['className'];
53
+		$shortcode = glsr(Shortcode::class);
54
+		if ('edit' == filter_input(INPUT_GET, 'context')) {
55
+			$this->filterBlockClass();
56
+			$this->filterFormFields();
57
+			$this->filterRatingField();
58
+			$this->filterSubmitButton();
59
+			if (!$this->hasVisibleFields($shortcode, $attributes)) {
60
+				$this->filterInterpolation();
61
+			}
62
+		}
63
+		return $shortcode->buildBlock($attributes);
64
+	}
65 65
 
66
-    /**
67
-     * @return void
68
-     */
69
-    protected function filterFormFields()
70
-    {
71
-        add_filter('site-reviews/config/forms/submission-form', function (array $config) {
72
-            array_walk($config, function (&$field) {
73
-                $field['disabled'] = true;
74
-                $field['tabindex'] = '-1';
75
-            });
76
-            return $config;
77
-        });
78
-    }
66
+	/**
67
+	 * @return void
68
+	 */
69
+	protected function filterFormFields()
70
+	{
71
+		add_filter('site-reviews/config/forms/submission-form', function (array $config) {
72
+			array_walk($config, function (&$field) {
73
+				$field['disabled'] = true;
74
+				$field['tabindex'] = '-1';
75
+			});
76
+			return $config;
77
+		});
78
+	}
79 79
 
80
-    /**
81
-     * @return void
82
-     */
83
-    protected function filterInterpolation()
84
-    {
85
-        add_filter('site-reviews/interpolate/reviews-form', function ($context) {
86
-            $context['class'] = 'glsr-default glsr-block-disabled';
87
-            $context['fields'] = _x('You have hidden all of the fields for this block.', 'admin-text', 'site-reviews');
88
-            $context['response'] = '';
89
-            $context['submit_button'] = '';
90
-            return $context;
91
-        });
92
-    }
80
+	/**
81
+	 * @return void
82
+	 */
83
+	protected function filterInterpolation()
84
+	{
85
+		add_filter('site-reviews/interpolate/reviews-form', function ($context) {
86
+			$context['class'] = 'glsr-default glsr-block-disabled';
87
+			$context['fields'] = _x('You have hidden all of the fields for this block.', 'admin-text', 'site-reviews');
88
+			$context['response'] = '';
89
+			$context['submit_button'] = '';
90
+			return $context;
91
+		});
92
+	}
93 93
 
94
-    /**
95
-     * @return void
96
-     */
97
-    protected function filterRatingField()
98
-    {
99
-        add_filter('site-reviews/rendered/field', function ($html, $type, $args) {
100
-            if ('rating' == $args['path']) {
101
-                $stars = '<span class="glsr-stars">';
102
-                $stars.= str_repeat('<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int) glsr()->constant('MAX_RATING', Rating::class));
103
-                $stars.= '</span>';
104
-                $html = preg_replace('/(.*)(<select.*)(<\/select>)(.*)/u', '$1'.$stars.'$4', $html);
105
-            }
106
-            return $html;
107
-        }, 10, 3);
108
-    }
94
+	/**
95
+	 * @return void
96
+	 */
97
+	protected function filterRatingField()
98
+	{
99
+		add_filter('site-reviews/rendered/field', function ($html, $type, $args) {
100
+			if ('rating' == $args['path']) {
101
+				$stars = '<span class="glsr-stars">';
102
+				$stars.= str_repeat('<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int) glsr()->constant('MAX_RATING', Rating::class));
103
+				$stars.= '</span>';
104
+				$html = preg_replace('/(.*)(<select.*)(<\/select>)(.*)/u', '$1'.$stars.'$4', $html);
105
+			}
106
+			return $html;
107
+		}, 10, 3);
108
+	}
109 109
 
110
-    /**
111
-     * @return void
112
-     */
113
-    protected function filterSubmitButton()
114
-    {
115
-        add_filter('site-reviews/rendered/template/form/submit-button', function ($template) {
116
-            return str_replace('type="submit"', 'tabindex="-1"', $template);
117
-        });
118
-    }
110
+	/**
111
+	 * @return void
112
+	 */
113
+	protected function filterSubmitButton()
114
+	{
115
+		add_filter('site-reviews/rendered/template/form/submit-button', function ($template) {
116
+			return str_replace('type="submit"', 'tabindex="-1"', $template);
117
+		});
118
+	}
119 119
 }
Please login to merge, or discard this patch.
plugin/Blocks/SiteReviewsBlock.php 1 patch
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -6,122 +6,122 @@
 block discarded – undo
6 6
 
7 7
 class SiteReviewsBlock extends BlockGenerator
8 8
 {
9
-    /**
10
-     * @return array
11
-     */
12
-    public function attributes()
13
-    {
14
-        return [
15
-            'assigned_to' => [
16
-                'default' => '',
17
-                'type' => 'string',
18
-            ],
19
-            'assigned_to_custom' => [
20
-                'default' => '',
21
-                'type' => 'string',
22
-            ],
23
-            'category' => [
24
-                'default' => '',
25
-                'type' => 'string',
26
-            ],
27
-            'className' => [
28
-                'default' => '',
29
-                'type' => 'string',
30
-            ],
31
-            'display' => [
32
-                'default' => 5,
33
-                'type' => 'number',
34
-            ],
35
-            'hide' => [
36
-                'default' => '',
37
-                'type' => 'string',
38
-            ],
39
-            'id' => [
40
-                'default' => '',
41
-                'type' => 'string',
42
-            ],
43
-            'pagination' => [
44
-                'default' => '',
45
-                'type' => 'string',
46
-            ],
47
-            'post_id' => [
48
-                'default' => '',
49
-                'type' => 'string',
50
-            ],
51
-            'rating' => [
52
-                'default' => 0,
53
-                'type' => 'number',
54
-            ],
55
-            'schema' => [
56
-                'default' => false,
57
-                'type' => 'boolean',
58
-            ],
59
-            'type' => [
60
-                'default' => 'local',
61
-                'type' => 'string',
62
-            ],
63
-            'user' => [
64
-                'default' => '',
65
-                'type' => 'string',
66
-            ],
67
-        ];
68
-    }
9
+	/**
10
+	 * @return array
11
+	 */
12
+	public function attributes()
13
+	{
14
+		return [
15
+			'assigned_to' => [
16
+				'default' => '',
17
+				'type' => 'string',
18
+			],
19
+			'assigned_to_custom' => [
20
+				'default' => '',
21
+				'type' => 'string',
22
+			],
23
+			'category' => [
24
+				'default' => '',
25
+				'type' => 'string',
26
+			],
27
+			'className' => [
28
+				'default' => '',
29
+				'type' => 'string',
30
+			],
31
+			'display' => [
32
+				'default' => 5,
33
+				'type' => 'number',
34
+			],
35
+			'hide' => [
36
+				'default' => '',
37
+				'type' => 'string',
38
+			],
39
+			'id' => [
40
+				'default' => '',
41
+				'type' => 'string',
42
+			],
43
+			'pagination' => [
44
+				'default' => '',
45
+				'type' => 'string',
46
+			],
47
+			'post_id' => [
48
+				'default' => '',
49
+				'type' => 'string',
50
+			],
51
+			'rating' => [
52
+				'default' => 0,
53
+				'type' => 'number',
54
+			],
55
+			'schema' => [
56
+				'default' => false,
57
+				'type' => 'boolean',
58
+			],
59
+			'type' => [
60
+				'default' => 'local',
61
+				'type' => 'string',
62
+			],
63
+			'user' => [
64
+				'default' => '',
65
+				'type' => 'string',
66
+			],
67
+		];
68
+	}
69 69
 
70
-    /**
71
-     * @return string
72
-     */
73
-    public function render(array $attributes)
74
-    {
75
-        $attributes['class'] = $attributes['className'];
76
-        $shortcode = glsr(Shortcode::class);
77
-        if ('edit' == filter_input(INPUT_GET, 'context')) {
78
-            $attributes = $this->normalize($attributes);
79
-            $this->filterBlockClass();
80
-            $this->filterReviewLinks();
81
-            $this->filterShowMoreLinks('content');
82
-            $this->filterShowMoreLinks('response');
83
-            if (!$this->hasVisibleFields($shortcode, $attributes)) {
84
-                $this->filterInterpolation();
85
-            }
86
-        }
87
-        return $shortcode->buildBlock($attributes);
88
-    }
70
+	/**
71
+	 * @return string
72
+	 */
73
+	public function render(array $attributes)
74
+	{
75
+		$attributes['class'] = $attributes['className'];
76
+		$shortcode = glsr(Shortcode::class);
77
+		if ('edit' == filter_input(INPUT_GET, 'context')) {
78
+			$attributes = $this->normalize($attributes);
79
+			$this->filterBlockClass();
80
+			$this->filterReviewLinks();
81
+			$this->filterShowMoreLinks('content');
82
+			$this->filterShowMoreLinks('response');
83
+			if (!$this->hasVisibleFields($shortcode, $attributes)) {
84
+				$this->filterInterpolation();
85
+			}
86
+		}
87
+		return $shortcode->buildBlock($attributes);
88
+	}
89 89
 
90
-    /**
91
-     * @return void
92
-     */
93
-    protected function filterInterpolation()
94
-    {
95
-        add_filter('site-reviews/interpolate/reviews', function ($context) {
96
-            $context['class'] = 'glsr-default glsr-block-disabled';
97
-            $context['reviews'] = _x('You have hidden all of the fields for this block.', 'admin-text', 'site-reviews');
98
-            return $context;
99
-        });
100
-    }
90
+	/**
91
+	 * @return void
92
+	 */
93
+	protected function filterInterpolation()
94
+	{
95
+		add_filter('site-reviews/interpolate/reviews', function ($context) {
96
+			$context['class'] = 'glsr-default glsr-block-disabled';
97
+			$context['reviews'] = _x('You have hidden all of the fields for this block.', 'admin-text', 'site-reviews');
98
+			return $context;
99
+		});
100
+	}
101 101
 
102
-    /**
103
-     * @return void
104
-     */
105
-    protected function filterReviewLinks()
106
-    {
107
-        add_filter('site-reviews/rendered/template/reviews', function ($template) {
108
-            return str_replace('<a', '<a tabindex="-1"', $template);
109
-        });
110
-    }
102
+	/**
103
+	 * @return void
104
+	 */
105
+	protected function filterReviewLinks()
106
+	{
107
+		add_filter('site-reviews/rendered/template/reviews', function ($template) {
108
+			return str_replace('<a', '<a tabindex="-1"', $template);
109
+		});
110
+	}
111 111
 
112
-    /**
113
-     * @param string $field
114
-     * @return void
115
-     */
116
-    protected function filterShowMoreLinks($field)
117
-    {
118
-        add_filter('site-reviews/review/wrap/'.$field, function ($value) {
119
-            $value = preg_replace(
120
-                '/(.*)(<span class="glsr-hidden)(.*)(<\/span>)(.*)/us',
121
-                '$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__('Show more', 'site-reviews').'</a>$5',
122
-                $value
123
-            );
124
-            return $value;
125
-        });
126
-    }
112
+	/**
113
+	 * @param string $field
114
+	 * @return void
115
+	 */
116
+	protected function filterShowMoreLinks($field)
117
+	{
118
+		add_filter('site-reviews/review/wrap/'.$field, function ($value) {
119
+			$value = preg_replace(
120
+				'/(.*)(<span class="glsr-hidden)(.*)(<\/span>)(.*)/us',
121
+				'$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__('Show more', 'site-reviews').'</a>$5',
122
+				$value
123
+			);
124
+			return $value;
125
+		});
126
+	}
127 127
 }
Please login to merge, or discard this patch.
plugin/Blocks/SiteReviewsSummaryBlock.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -6,81 +6,81 @@
 block discarded – undo
6 6
 
7 7
 class SiteReviewsSummaryBlock extends BlockGenerator
8 8
 {
9
-    /**
10
-     * @return array
11
-     */
12
-    public function attributes()
13
-    {
14
-        return [
15
-            'assigned_to' => [
16
-                'default' => '',
17
-                'type' => 'string',
18
-            ],
19
-            'assigned_to_custom' => [
20
-                'default' => '',
21
-                'type' => 'string',
22
-            ],
23
-            'category' => [
24
-                'default' => '',
25
-                'type' => 'string',
26
-            ],
27
-            'className' => [
28
-                'default' => '',
29
-                'type' => 'string',
30
-            ],
31
-            'hide' => [
32
-                'default' => '',
33
-                'type' => 'string',
34
-            ],
35
-            'post_id' => [
36
-                'default' => '',
37
-                'type' => 'string',
38
-            ],
39
-            'rating' => [
40
-                'default' => '1',
41
-                'type' => 'number',
42
-            ],
43
-            'schema' => [
44
-                'default' => false,
45
-                'type' => 'boolean',
46
-            ],
47
-            'type' => [
48
-                'default' => 'local',
49
-                'type' => 'string',
50
-            ],
51
-            'user' => [
52
-                'default' => '',
53
-                'type' => 'string',
54
-            ],
55
-        ];
56
-    }
9
+	/**
10
+	 * @return array
11
+	 */
12
+	public function attributes()
13
+	{
14
+		return [
15
+			'assigned_to' => [
16
+				'default' => '',
17
+				'type' => 'string',
18
+			],
19
+			'assigned_to_custom' => [
20
+				'default' => '',
21
+				'type' => 'string',
22
+			],
23
+			'category' => [
24
+				'default' => '',
25
+				'type' => 'string',
26
+			],
27
+			'className' => [
28
+				'default' => '',
29
+				'type' => 'string',
30
+			],
31
+			'hide' => [
32
+				'default' => '',
33
+				'type' => 'string',
34
+			],
35
+			'post_id' => [
36
+				'default' => '',
37
+				'type' => 'string',
38
+			],
39
+			'rating' => [
40
+				'default' => '1',
41
+				'type' => 'number',
42
+			],
43
+			'schema' => [
44
+				'default' => false,
45
+				'type' => 'boolean',
46
+			],
47
+			'type' => [
48
+				'default' => 'local',
49
+				'type' => 'string',
50
+			],
51
+			'user' => [
52
+				'default' => '',
53
+				'type' => 'string',
54
+			],
55
+		];
56
+	}
57 57
 
58
-    /**
59
-     * @return string
60
-     */
61
-    public function render(array $attributes)
62
-    {
63
-        $attributes['class'] = $attributes['className'];
64
-        $shortcode = glsr(Shortcode::class);
65
-        if ('edit' == filter_input(INPUT_GET, 'context')) {
66
-            $attributes = $this->normalize($attributes);
67
-            $this->filterBlockClass();
68
-            if (!$this->hasVisibleFields($shortcode, $attributes)) {
69
-                $this->filterInterpolation();
70
-            }
71
-        }
72
-        return $shortcode->buildBlock($attributes);
73
-    }
58
+	/**
59
+	 * @return string
60
+	 */
61
+	public function render(array $attributes)
62
+	{
63
+		$attributes['class'] = $attributes['className'];
64
+		$shortcode = glsr(Shortcode::class);
65
+		if ('edit' == filter_input(INPUT_GET, 'context')) {
66
+			$attributes = $this->normalize($attributes);
67
+			$this->filterBlockClass();
68
+			if (!$this->hasVisibleFields($shortcode, $attributes)) {
69
+				$this->filterInterpolation();
70
+			}
71
+		}
72
+		return $shortcode->buildBlock($attributes);
73
+	}
74 74
 
75
-    /**
76
-     * @return void
77
-     */
78
-    protected function filterInterpolation()
79
-    {
80
-        add_filter('site-reviews/interpolate/reviews-summary', function ($context) {
81
-            $context['class'] = 'glsr-default glsr-block-disabled';
82
-            $context['text'] = _x('You have hidden all of the fields for this block.', 'admin-text', 'site-reviews');
83
-            return $context;
84
-        });
85
-    }
75
+	/**
76
+	 * @return void
77
+	 */
78
+	protected function filterInterpolation()
79
+	{
80
+		add_filter('site-reviews/interpolate/reviews-summary', function ($context) {
81
+			$context['class'] = 'glsr-default glsr-block-disabled';
82
+			$context['text'] = _x('You have hidden all of the fields for this block.', 'admin-text', 'site-reviews');
83
+			return $context;
84
+		});
85
+	}
86 86
 }
Please login to merge, or discard this patch.
plugin/Defaults/SiteReviewsSummaryDefaults.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -6,34 +6,34 @@
 block discarded – undo
6 6
 
7 7
 class SiteReviewsSummaryDefaults extends Defaults
8 8
 {
9
-    /**
10
-     * @var array
11
-     */
12
-    protected $guarded = [
13
-        'labels',
14
-        'text',
15
-        'title',
16
-    ];
9
+	/**
10
+	 * @var array
11
+	 */
12
+	protected $guarded = [
13
+		'labels',
14
+		'text',
15
+		'title',
16
+	];
17 17
 
18
-    /**
19
-     * @return array
20
-     */
21
-    protected function defaults()
22
-    {
23
-        return [
24
-            'assigned_to' => '',
25
-            'assigned_to_custom' => '',
26
-            'category' => '',
27
-            'class' => '',
28
-            'hide' => '',
29
-            'id' => '',
30
-            'labels' => '',
31
-            'rating' => 1,
32
-            'schema' => false,
33
-            'text' => '',
34
-            'title' => '',
35
-            'type' => 'local',
36
-            'user' => '',
37
-        ];
38
-    }
18
+	/**
19
+	 * @return array
20
+	 */
21
+	protected function defaults()
22
+	{
23
+		return [
24
+			'assigned_to' => '',
25
+			'assigned_to_custom' => '',
26
+			'category' => '',
27
+			'class' => '',
28
+			'hide' => '',
29
+			'id' => '',
30
+			'labels' => '',
31
+			'rating' => 1,
32
+			'schema' => false,
33
+			'text' => '',
34
+			'title' => '',
35
+			'type' => 'local',
36
+			'user' => '',
37
+		];
38
+	}
39 39
 }
Please login to merge, or discard this patch.
plugin/Defaults/SiteReviewsFormDefaults.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -6,30 +6,30 @@
 block discarded – undo
6 6
 
7 7
 class SiteReviewsFormDefaults extends Defaults
8 8
 {
9
-    /**
10
-     * @var array
11
-     */
12
-    protected $guarded = [
13
-        'description',
14
-        'title',
15
-    ];
9
+	/**
10
+	 * @var array
11
+	 */
12
+	protected $guarded = [
13
+		'description',
14
+		'title',
15
+	];
16 16
 
17
-    /**
18
-     * @return array
19
-     */
20
-    protected function defaults()
21
-    {
22
-        return [
23
-            'assign_to' => '',
24
-            'assign_to_custom' => '',
25
-            'category' => '',
26
-            'class' => '',
27
-            'description' => '',
28
-            'excluded' => '',
29
-            'hide' => '',
30
-            'id' => '',
31
-            'title' => '',
32
-            'user' => '',
33
-        ];
34
-    }
17
+	/**
18
+	 * @return array
19
+	 */
20
+	protected function defaults()
21
+	{
22
+		return [
23
+			'assign_to' => '',
24
+			'assign_to_custom' => '',
25
+			'category' => '',
26
+			'class' => '',
27
+			'description' => '',
28
+			'excluded' => '',
29
+			'hide' => '',
30
+			'id' => '',
31
+			'title' => '',
32
+			'user' => '',
33
+		];
34
+	}
35 35
 }
Please login to merge, or discard this patch.
plugin/Helpers/Str.php 1 patch
Indentation   +270 added lines, -270 removed lines patch added patch discarded remove patch
@@ -4,294 +4,294 @@
 block discarded – undo
4 4
 
5 5
 class Str
6 6
 {
7
-    /**
8
-     * @param string $subject
9
-     * @param string $search
10
-     * @return string
11
-     */
12
-    public static function afterLast($subject, $search)
13
-    {
14
-        return '' === $search
15
-            ? $subject
16
-            : array_reverse(explode($search, $subject))[0];
17
-    }
7
+	/**
8
+	 * @param string $subject
9
+	 * @param string $search
10
+	 * @return string
11
+	 */
12
+	public static function afterLast($subject, $search)
13
+	{
14
+		return '' === $search
15
+			? $subject
16
+			: array_reverse(explode($search, $subject))[0];
17
+	}
18 18
 
19
-    /**
20
-     * @param string $subject
21
-     * @param string $search
22
-     * @return string
23
-     */
24
-    public static function before($subject, $search)
25
-    {
26
-        return $search === '' ? $subject : explode($search, $subject)[0];
27
-    }
19
+	/**
20
+	 * @param string $subject
21
+	 * @param string $search
22
+	 * @return string
23
+	 */
24
+	public static function before($subject, $search)
25
+	{
26
+		return $search === '' ? $subject : explode($search, $subject)[0];
27
+	}
28 28
 
29
-    /**
30
-     * @param string $string
31
-     * @return string
32
-     */
33
-    public static function camelCase($string)
34
-    {
35
-        $string = ucwords(str_replace(['-', '_'], ' ', trim($string)));
36
-        return str_replace(' ', '', $string);
37
-    }
29
+	/**
30
+	 * @param string $string
31
+	 * @return string
32
+	 */
33
+	public static function camelCase($string)
34
+	{
35
+		$string = ucwords(str_replace(['-', '_'], ' ', trim($string)));
36
+		return str_replace(' ', '', $string);
37
+	}
38 38
 
39
-    /**
40
-     * @param string $haystack
41
-     * @param string $needle
42
-     * @return bool
43
-     */
44
-    public static function contains($haystack, $needle)
45
-    {
46
-        return !empty($needle) && false !== strpos($haystack, $needle);
47
-    }
39
+	/**
40
+	 * @param string $haystack
41
+	 * @param string $needle
42
+	 * @return bool
43
+	 */
44
+	public static function contains($haystack, $needle)
45
+	{
46
+		return !empty($needle) && false !== strpos($haystack, $needle);
47
+	}
48 48
 
49
-    /**
50
-     * @param string $name
51
-     * @param string $nameType first|first_initial|initials|last|last_initial
52
-     * @param string $initialType period|period_space|space
53
-     * @return string
54
-     */
55
-    public static function convertName($name, $nameType = '', $initialType = '')
56
-    {
57
-        $names = preg_split('/\W/', $name, 0, PREG_SPLIT_NO_EMPTY);
58
-        $firstName = array_shift($names);
59
-        $lastName = array_pop($names);
60
-        $initialTypes = [
61
-            'period' => '.',
62
-            'period_space' => '. ',
63
-            'space' => ' ',
64
-        ];
65
-        $initialPunctuation = (string) Arr::get($initialTypes, $initialType, ' ');
66
-        if ('initials' == $nameType) {
67
-            return static::convertToInitials($name, $initialPunctuation);
68
-        }
69
-        $nameTypes = [
70
-            'first' => $firstName,
71
-            'first_initial' => substr($firstName, 0, 1).$initialPunctuation.$lastName,
72
-            'last' => $lastName,
73
-            'last_initial' => $firstName.' '.substr($lastName, 0, 1).$initialPunctuation,
74
-        ];
75
-        return trim((string) Arr::get($nameTypes, $nameType, $name));
76
-    }
49
+	/**
50
+	 * @param string $name
51
+	 * @param string $nameType first|first_initial|initials|last|last_initial
52
+	 * @param string $initialType period|period_space|space
53
+	 * @return string
54
+	 */
55
+	public static function convertName($name, $nameType = '', $initialType = '')
56
+	{
57
+		$names = preg_split('/\W/', $name, 0, PREG_SPLIT_NO_EMPTY);
58
+		$firstName = array_shift($names);
59
+		$lastName = array_pop($names);
60
+		$initialTypes = [
61
+			'period' => '.',
62
+			'period_space' => '. ',
63
+			'space' => ' ',
64
+		];
65
+		$initialPunctuation = (string) Arr::get($initialTypes, $initialType, ' ');
66
+		if ('initials' == $nameType) {
67
+			return static::convertToInitials($name, $initialPunctuation);
68
+		}
69
+		$nameTypes = [
70
+			'first' => $firstName,
71
+			'first_initial' => substr($firstName, 0, 1).$initialPunctuation.$lastName,
72
+			'last' => $lastName,
73
+			'last_initial' => $firstName.' '.substr($lastName, 0, 1).$initialPunctuation,
74
+		];
75
+		return trim((string) Arr::get($nameTypes, $nameType, $name));
76
+	}
77 77
 
78
-    /**
79
-     * @param string $path
80
-     * @param string $prefix
81
-     * @return string
82
-     */
83
-    public static function convertPathToId($path, $prefix = '')
84
-    {
85
-        return str_replace(['[', ']'], ['-', ''], static::convertPathToName($path, $prefix));
86
-    }
78
+	/**
79
+	 * @param string $path
80
+	 * @param string $prefix
81
+	 * @return string
82
+	 */
83
+	public static function convertPathToId($path, $prefix = '')
84
+	{
85
+		return str_replace(['[', ']'], ['-', ''], static::convertPathToName($path, $prefix));
86
+	}
87 87
 
88
-    /**
89
-     * @param string $path
90
-     * @param string $prefix
91
-     * @return string
92
-     */
93
-    public static function convertPathToName($path, $prefix = '')
94
-    {
95
-        $levels = explode('.', $path);
96
-        return array_reduce($levels, function ($result, $value) {
97
-            return $result .= '['.$value.']';
98
-        }, $prefix);
99
-    }
88
+	/**
89
+	 * @param string $path
90
+	 * @param string $prefix
91
+	 * @return string
92
+	 */
93
+	public static function convertPathToName($path, $prefix = '')
94
+	{
95
+		$levels = explode('.', $path);
96
+		return array_reduce($levels, function ($result, $value) {
97
+			return $result .= '['.$value.']';
98
+		}, $prefix);
99
+	}
100 100
 
101
-    /**
102
-     * @param string $name
103
-     * @param string $initialPunctuation
104
-     * @return string
105
-     */
106
-    public static function convertToInitials($name, $initialPunctuation = '')
107
-    {
108
-        preg_match_all('/(?<=\s|\b)\pL/u', $name, $matches);
109
-        return array_reduce($matches[0], function ($carry, $word) use ($initialPunctuation) {
110
-            return $carry.strtoupper(substr($word, 0, 1)).$initialPunctuation;
111
-        });
112
-    }
101
+	/**
102
+	 * @param string $name
103
+	 * @param string $initialPunctuation
104
+	 * @return string
105
+	 */
106
+	public static function convertToInitials($name, $initialPunctuation = '')
107
+	{
108
+		preg_match_all('/(?<=\s|\b)\pL/u', $name, $matches);
109
+		return array_reduce($matches[0], function ($carry, $word) use ($initialPunctuation) {
110
+			return $carry.strtoupper(substr($word, 0, 1)).$initialPunctuation;
111
+		});
112
+	}
113 113
 
114
-    /**
115
-     * @param string $string
116
-     * @return string
117
-     */
118
-    public static function dashCase($string)
119
-    {
120
-        return str_replace('_', '-', static::snakeCase($string));
121
-    }
114
+	/**
115
+	 * @param string $string
116
+	 * @return string
117
+	 */
118
+	public static function dashCase($string)
119
+	{
120
+		return str_replace('_', '-', static::snakeCase($string));
121
+	}
122 122
 
123
-    /**
124
-     * @param string $needle
125
-     * @param string $haystack
126
-     * @return bool
127
-     */
128
-    public static function endsWith($needle, $haystack)
129
-    {
130
-        $length = strlen($needle);
131
-        return 0 != $length
132
-            ? substr($haystack, -$length) === $needle
133
-            : true;
134
-    }
123
+	/**
124
+	 * @param string $needle
125
+	 * @param string $haystack
126
+	 * @return bool
127
+	 */
128
+	public static function endsWith($needle, $haystack)
129
+	{
130
+		$length = strlen($needle);
131
+		return 0 != $length
132
+			? substr($haystack, -$length) === $needle
133
+			: true;
134
+	}
135 135
 
136
-    /**
137
-     * @param mixed $value
138
-     * @param string $fallback
139
-     * @return string
140
-     */
141
-    public static function fallback($value, $fallback)
142
-    {
143
-        return is_string($value) && empty(trim($value))
144
-            ? $fallback
145
-            : $value;
146
-    }
136
+	/**
137
+	 * @param mixed $value
138
+	 * @param string $fallback
139
+	 * @return string
140
+	 */
141
+	public static function fallback($value, $fallback)
142
+	{
143
+		return is_string($value) && empty(trim($value))
144
+			? $fallback
145
+			: $value;
146
+	}
147 147
 
148
-    /**
149
-     * @return string
150
-     */
151
-    public static function naturalJoin(array $values)
152
-    {
153
-        $and = __('and', 'site-reviews');
154
-        $values[] = implode(' '.$and.' ', array_splice($values, -2));
155
-        return implode(', ', $values);
156
-    }
148
+	/**
149
+	 * @return string
150
+	 */
151
+	public static function naturalJoin(array $values)
152
+	{
153
+		$and = __('and', 'site-reviews');
154
+		$values[] = implode(' '.$and.' ', array_splice($values, -2));
155
+		return implode(', ', $values);
156
+	}
157 157
 
158
-    /**
159
-     * @param string $prefix
160
-     * @param string $string
161
-     * @param string|null $trim
162
-     * @return string
163
-     */
164
-    public static function prefix($prefix, $string, $trim = null)
165
-    {
166
-        if (empty($string)) {
167
-            return $string;
168
-        }
169
-        if (null === $trim) {
170
-            $trim = $prefix;
171
-        }
172
-        return $prefix.trim(static::removePrefix($trim, $string));
173
-    }
158
+	/**
159
+	 * @param string $prefix
160
+	 * @param string $string
161
+	 * @param string|null $trim
162
+	 * @return string
163
+	 */
164
+	public static function prefix($prefix, $string, $trim = null)
165
+	{
166
+		if (empty($string)) {
167
+			return $string;
168
+		}
169
+		if (null === $trim) {
170
+			$trim = $prefix;
171
+		}
172
+		return $prefix.trim(static::removePrefix($trim, $string));
173
+	}
174 174
 
175
-    /**
176
-     * @param int $length
177
-     * @return string
178
-     */
179
-    public static function random($length = 8)
180
-    {
181
-        $text = base64_encode(wp_generate_password());
182
-        return substr(str_replace(['/','+','='], '', $text), 0, $length);
183
-    }
175
+	/**
176
+	 * @param int $length
177
+	 * @return string
178
+	 */
179
+	public static function random($length = 8)
180
+	{
181
+		$text = base64_encode(wp_generate_password());
182
+		return substr(str_replace(['/','+','='], '', $text), 0, $length);
183
+	}
184 184
 
185
-    /**
186
-     * @param string $prefix
187
-     * @param string $string
188
-     * @return string
189
-     */
190
-    public static function removePrefix($prefix, $string)
191
-    {
192
-        return static::startsWith($prefix, $string)
193
-            ? substr($string, strlen($prefix))
194
-            : $string;
195
-    }
185
+	/**
186
+	 * @param string $prefix
187
+	 * @param string $string
188
+	 * @return string
189
+	 */
190
+	public static function removePrefix($prefix, $string)
191
+	{
192
+		return static::startsWith($prefix, $string)
193
+			? substr($string, strlen($prefix))
194
+			: $string;
195
+	}
196 196
 
197
-    /**
198
-     * @param string $search
199
-     * @param string $replace
200
-     * @param string $subject
201
-     * @return string
202
-     */
203
-    public static function replaceFirst($search, $replace, $subject)
204
-    {
205
-        if ($search == '') {
206
-            return $subject;
207
-        }
208
-        $position = strpos($subject, $search);
209
-        if ($position !== false) {
210
-            return substr_replace($subject, $replace, $position, strlen($search));
211
-        }
212
-        return $subject;
213
-    }
197
+	/**
198
+	 * @param string $search
199
+	 * @param string $replace
200
+	 * @param string $subject
201
+	 * @return string
202
+	 */
203
+	public static function replaceFirst($search, $replace, $subject)
204
+	{
205
+		if ($search == '') {
206
+			return $subject;
207
+		}
208
+		$position = strpos($subject, $search);
209
+		if ($position !== false) {
210
+			return substr_replace($subject, $replace, $position, strlen($search));
211
+		}
212
+		return $subject;
213
+	}
214 214
 
215
-    /**
216
-     * @param string $search
217
-     * @param string $replace
218
-     * @param string $subject
219
-     * @return string
220
-     */
221
-    public static function replaceLast($search, $replace, $subject)
222
-    {
223
-        $position = strrpos($subject, $search);
224
-        if ($position !== false) {
225
-            return substr_replace($subject, $replace, $position, strlen($search));
226
-        }
227
-        return $subject;
228
-    }
215
+	/**
216
+	 * @param string $search
217
+	 * @param string $replace
218
+	 * @param string $subject
219
+	 * @return string
220
+	 */
221
+	public static function replaceLast($search, $replace, $subject)
222
+	{
223
+		$position = strrpos($subject, $search);
224
+		if ($position !== false) {
225
+			return substr_replace($subject, $replace, $position, strlen($search));
226
+		}
227
+		return $subject;
228
+	}
229 229
 
230
-    /**
231
-     * @param string|array $restrictions
232
-     * @param string $value
233
-     * @param string $fallback
234
-     * @param bool $strict
235
-     * @return string
236
-     */
237
-    public static function restrictTo($restrictions, $value, $fallback = '', $strict = false)
238
-    {
239
-        $needle = $value;
240
-        $haystack = static::toArray($restrictions);
241
-        if (true !== $strict) {
242
-            $needle = strtolower($needle);
243
-            $haystack = array_map('strtolower', $haystack);
244
-        }
245
-        return in_array($needle, $haystack)
246
-            ? $value
247
-            : $fallback;
248
-    }
230
+	/**
231
+	 * @param string|array $restrictions
232
+	 * @param string $value
233
+	 * @param string $fallback
234
+	 * @param bool $strict
235
+	 * @return string
236
+	 */
237
+	public static function restrictTo($restrictions, $value, $fallback = '', $strict = false)
238
+	{
239
+		$needle = $value;
240
+		$haystack = static::toArray($restrictions);
241
+		if (true !== $strict) {
242
+			$needle = strtolower($needle);
243
+			$haystack = array_map('strtolower', $haystack);
244
+		}
245
+		return in_array($needle, $haystack)
246
+			? $value
247
+			: $fallback;
248
+	}
249 249
 
250
-    /**
251
-     * @param string $string
252
-     * @return string
253
-     */
254
-    public static function snakeCase($string)
255
-    {
256
-        if (!ctype_lower($string)) {
257
-            $string = preg_replace('/\s+/u', '', $string);
258
-            $string = preg_replace('/(.)(?=[A-Z])/u', '$1_', $string);
259
-            $string = function_exists('mb_strtolower')
260
-                ? mb_strtolower($string, 'UTF-8')
261
-                : strtolower($string);
262
-        }
263
-        return str_replace('-', '_', $string);
264
-    }
250
+	/**
251
+	 * @param string $string
252
+	 * @return string
253
+	 */
254
+	public static function snakeCase($string)
255
+	{
256
+		if (!ctype_lower($string)) {
257
+			$string = preg_replace('/\s+/u', '', $string);
258
+			$string = preg_replace('/(.)(?=[A-Z])/u', '$1_', $string);
259
+			$string = function_exists('mb_strtolower')
260
+				? mb_strtolower($string, 'UTF-8')
261
+				: strtolower($string);
262
+		}
263
+		return str_replace('-', '_', $string);
264
+	}
265 265
 
266
-    /**
267
-     * @param string $needle
268
-     * @param string $haystack
269
-     * @return bool
270
-     */
271
-    public static function startsWith($needle, $haystack)
272
-    {
273
-        return substr($haystack, 0, strlen($needle)) === $needle;
274
-    }
266
+	/**
267
+	 * @param string $needle
268
+	 * @param string $haystack
269
+	 * @return bool
270
+	 */
271
+	public static function startsWith($needle, $haystack)
272
+	{
273
+		return substr($haystack, 0, strlen($needle)) === $needle;
274
+	}
275 275
 
276
-    /**
277
-     * @param string $string
278
-     * @param int $length
279
-     * @return string
280
-     */
281
-    public static function truncate($string, $length)
282
-    {
283
-        return strlen($string) > $length
284
-            ? substr($string, 0, $length)
285
-            : $string;
286
-    }
287
-    /**
288
-     * @param mixed $value
289
-     * @return array
290
-     */
291
-    public static function toArray($value)
292
-    {
293
-        return is_string($value)
294
-            ? array_map('trim', explode(',', $value))
295
-            : Arr::consolidate($value);
296
-    }
276
+	/**
277
+	 * @param string $string
278
+	 * @param int $length
279
+	 * @return string
280
+	 */
281
+	public static function truncate($string, $length)
282
+	{
283
+		return strlen($string) > $length
284
+			? substr($string, 0, $length)
285
+			: $string;
286
+	}
287
+	/**
288
+	 * @param mixed $value
289
+	 * @return array
290
+	 */
291
+	public static function toArray($value)
292
+	{
293
+		return is_string($value)
294
+			? array_map('trim', explode(',', $value))
295
+			: Arr::consolidate($value);
296
+	}
297 297
 }
Please login to merge, or discard this patch.
plugin/Shortcodes/SiteReviewsShortcode.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -4,17 +4,17 @@
 block discarded – undo
4 4
 
5 5
 class SiteReviewsShortcode extends Shortcode
6 6
 {
7
-    protected function hideOptions()
8
-    {
9
-        return [
10
-            'title' => _x('Hide the title', 'admin-text', 'site-reviews'),
11
-            'rating' => _x('Hide the rating', 'admin-text', 'site-reviews'),
12
-            'date' => _x('Hide the date', 'admin-text', 'site-reviews'),
13
-            'assigned_to' => _x('Hide the assigned to links (if shown)', 'admin-text', 'site-reviews'),
14
-            'content' => _x('Hide the content', 'admin-text', 'site-reviews'),
15
-            'avatar' => _x('Hide the avatar (if shown)', 'admin-text', 'site-reviews'),
16
-            'author' => _x('Hide the author', 'admin-text', 'site-reviews'),
17
-            'response' => _x('Hide the response', 'admin-text', 'site-reviews'),
18
-        ];
19
-    }
7
+	protected function hideOptions()
8
+	{
9
+		return [
10
+			'title' => _x('Hide the title', 'admin-text', 'site-reviews'),
11
+			'rating' => _x('Hide the rating', 'admin-text', 'site-reviews'),
12
+			'date' => _x('Hide the date', 'admin-text', 'site-reviews'),
13
+			'assigned_to' => _x('Hide the assigned to links (if shown)', 'admin-text', 'site-reviews'),
14
+			'content' => _x('Hide the content', 'admin-text', 'site-reviews'),
15
+			'avatar' => _x('Hide the avatar (if shown)', 'admin-text', 'site-reviews'),
16
+			'author' => _x('Hide the author', 'admin-text', 'site-reviews'),
17
+			'response' => _x('Hide the response', 'admin-text', 'site-reviews'),
18
+		];
19
+	}
20 20
 }
Please login to merge, or discard this patch.
plugin/Modules/Html/Attributes.php 1 patch
Indentation   +288 added lines, -288 removed lines patch added patch discarded remove patch
@@ -7,292 +7,292 @@
 block discarded – undo
7 7
 
8 8
 class Attributes
9 9
 {
10
-    const ATTRIBUTES_A = [
11
-        'download', 'href', 'hreflang', 'ping', 'referrerpolicy', 'rel', 'target', 'type',
12
-    ];
13
-
14
-    const ATTRIBUTES_BUTTON = [
15
-        'autofocus', 'disabled', 'form', 'formaction', 'formenctype', 'formmethod',
16
-        'formnovalidate', 'formtarget', 'name', 'type', 'value',
17
-    ];
18
-
19
-    const ATTRIBUTES_FORM = [
20
-        'accept', 'accept-charset', 'action', 'autocapitalize', 'autocomplete', 'enctype', 'method',
21
-        'name', 'novalidate', 'target',
22
-    ];
23
-
24
-    const ATTRIBUTES_IMG = [
25
-        'alt', 'crossorigin', 'decoding', 'height', 'ismap', 'loading', 'referrerpolicy', 'sizes', 
26
-        'src', 'srcset', 'width', 'usemap',
27
-    ];
28
-
29
-    const ATTRIBUTES_INPUT = [
30
-        'accept', 'autocomplete', 'autocorrect', 'autofocus', 'capture', 'checked', 'disabled',
31
-        'form', 'formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget', 'height',
32
-        'incremental', 'inputmode', 'list', 'max', 'maxlength', 'min', 'minlength', 'multiple',
33
-        'name', 'pattern', 'placeholder', 'readonly', 'results', 'required', 'selectionDirection',
34
-        'selectionEnd', 'selectionStart', 'size', 'spellcheck', 'src', 'step', 'tabindex', 'type',
35
-        'value', 'webkitdirectory', 'width',
36
-    ];
37
-
38
-    const ATTRIBUTES_LABEL = [
39
-        'for',
40
-    ];
41
-
42
-    const ATTRIBUTES_OPTION = [
43
-        'disabled', 'label', 'selected', 'value',
44
-    ];
45
-
46
-    const ATTRIBUTES_SELECT = [
47
-        'autofocus', 'disabled', 'form', 'multiple', 'name', 'required', 'size',
48
-    ];
49
-
50
-    const ATTRIBUTES_TEXTAREA = [
51
-        'autocapitalize', 'autocomplete', 'autofocus', 'cols', 'disabled', 'form', 'maxlength',
52
-        'minlength', 'name', 'placeholder', 'readonly', 'required', 'rows', 'spellcheck', 'wrap',
53
-    ];
54
-
55
-    const BOOLEAN_ATTRIBUTES = [
56
-        'autofocus', 'capture', 'checked', 'disabled', 'draggable', 'formnovalidate', 'hidden',
57
-        'multiple', 'novalidate', 'readonly', 'required', 'selected', 'spellcheck',
58
-        'webkitdirectory',
59
-    ];
60
-
61
-    const GLOBAL_ATTRIBUTES = [
62
-        'accesskey', 'class', 'contenteditable', 'contextmenu', 'dir', 'draggable', 'dropzone',
63
-        'hidden', 'id', 'lang', 'spellcheck', 'style', 'tabindex', 'title',
64
-    ];
65
-
66
-    const GLOBAL_WILDCARD_ATTRIBUTES = [
67
-        'aria-', 'data-', 'item', 'on',
68
-    ];
69
-
70
-    const INPUT_TYPES = [
71
-        'button', 'checkbox', 'color', 'date', 'datetime-local', 'email', 'file', 'hidden', 'image',
72
-        'month', 'number', 'password', 'radio', 'range', 'reset', 'search', 'submit', 'tel', 'text',
73
-        'time', 'url', 'week',
74
-    ];
75
-
76
-    /**
77
-     * @var array
78
-     */
79
-    protected $attributes = [];
80
-
81
-    /**
82
-     * @param string $method
83
-     * @param array $args
84
-     * @return static
85
-     */
86
-    public function __call($method, $args)
87
-    {
88
-        $constant = 'static::ATTRIBUTES_'.strtoupper($method);
89
-        $allowedAttributeKeys = defined($constant)
90
-            ? constant($constant)
91
-            : [];
92
-        $this->normalize(Arr::consolidate(Arr::get($args, 0)), $allowedAttributeKeys);
93
-        $this->normalizeInputType($method);
94
-        return $this;
95
-    }
96
-
97
-    /**
98
-     * @return static
99
-     */
100
-    public function set(array $attributes)
101
-    {
102
-        $this->normalize($attributes);
103
-        return $this;
104
-    }
105
-
106
-    /**
107
-     * @return array
108
-     */
109
-    public function toArray()
110
-    {
111
-        return $this->attributes;
112
-    }
113
-
114
-    /**
115
-     * @return string
116
-     */
117
-    public function toString()
118
-    {
119
-        $attributes = [];
120
-        foreach ($this->attributes as $attribute => $value) {
121
-            $quote = $this->getQuoteChar($attribute);
122
-            $attributes[] = in_array($attribute, static::BOOLEAN_ATTRIBUTES)
123
-                ? $attribute
124
-                : $attribute.'='.$quote.implode(',', (array) $value).$quote;
125
-        }
126
-        return implode(' ', $attributes);
127
-    }
128
-
129
-    /**
130
-     * @return array
131
-     */
132
-    protected function filterAttributes(array $allowedAttributeKeys)
133
-    {
134
-        return array_intersect_key($this->attributes, array_flip($allowedAttributeKeys));
135
-    }
136
-
137
-    /**
138
-     * @return array
139
-     */
140
-    protected function filterGlobalAttributes()
141
-    {
142
-        $globalAttributes = $this->filterAttributes(static::GLOBAL_ATTRIBUTES);
143
-        $wildcards = [];
144
-        foreach (static::GLOBAL_WILDCARD_ATTRIBUTES as $wildcard) {
145
-            $newWildcards = array_filter($this->attributes, function ($key) use ($wildcard) {
146
-                return Str::startsWith($wildcard, $key);
147
-            }, ARRAY_FILTER_USE_KEY);
148
-            $wildcards = array_merge($wildcards, $newWildcards);
149
-        }
150
-        return array_merge($globalAttributes, $wildcards);
151
-    }
152
-
153
-    /**
154
-     * @return array
155
-     */
156
-    protected function getPermanentAttributes()
157
-    {
158
-        $permanentAttributes = [];
159
-        if (array_key_exists('value', $this->attributes)) {
160
-            $permanentAttributes['value'] = $this->attributes['value'];
161
-        }
162
-        return $permanentAttributes;
163
-    }
164
-
165
-    /**
166
-     * @param string $attribute
167
-     * @return string
168
-     */
169
-    protected function getQuoteChar($attribute)
170
-    {
171
-        return Str::startsWith('data-', $attribute)
172
-            ? '\''
173
-            : '"';
174
-    }
175
-
176
-    /**
177
-     * @param string $key
178
-     * @param mixed $value
179
-     * @return bool
180
-     */
181
-    protected function isAttributeKeyNumeric($key, $value)
182
-    {
183
-        return is_string($value)
184
-            && is_numeric($key)
185
-            && !array_key_exists($value, $this->attributes);
186
-    }
187
-
188
-    /**
189
-     * @return void
190
-     */
191
-    protected function normalize(array $args, array $allowedAttributeKeys = [])
192
-    {
193
-        $this->attributes = array_change_key_case($args, CASE_LOWER);
194
-        $this->normalizeBooleanAttributes();
195
-        $this->normalizeDataAttributes();
196
-        $this->normalizeStringAttributes();
197
-        $this->removeEmptyAttributes();
198
-        $this->removeIndexedAttributes();
199
-        $this->attributes = array_merge(
200
-            $this->filterGlobalAttributes(),
201
-            $this->filterAttributes($allowedAttributeKeys)
202
-        );
203
-    }
204
-
205
-    /**
206
-     * @return void
207
-     */
208
-    protected function normalizeBooleanAttributes()
209
-    {
210
-        foreach ($this->attributes as $key => $value) {
211
-            if ($this->isAttributeKeyNumeric($key, $value)) {
212
-                $key = $value;
213
-                $value = true;
214
-            }
215
-            if (!in_array($key, static::BOOLEAN_ATTRIBUTES)) {
216
-                continue;
217
-            }
218
-            $this->attributes[$key] = wp_validate_boolean($value);
219
-        }
220
-    }
221
-
222
-    /**
223
-     * @return void
224
-     */
225
-    protected function normalizeDataAttributes()
226
-    {
227
-        foreach ($this->attributes as $key => $value) {
228
-            if ($this->isAttributeKeyNumeric($key, $value)) {
229
-                $key = $value;
230
-                $value = '';
231
-            }
232
-            if (!Str::startsWith('data-', $key)) {
233
-                continue;
234
-            }
235
-            if (is_array($value)) {
236
-                $value = json_encode($value, JSON_HEX_APOS | JSON_NUMERIC_CHECK | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
237
-            }
238
-            $this->attributes[$key] = $value;
239
-        }
240
-    }
241
-
242
-    /**
243
-     * @return void
244
-     */
245
-    protected function normalizeStringAttributes()
246
-    {
247
-        foreach ($this->attributes as $key => $value) {
248
-            if (is_string($value)) {
249
-                $this->attributes[$key] = trim($value);
250
-            }
251
-        }
252
-    }
253
-
254
-    /**
255
-     * @param string $method
256
-     * @return void
257
-     */
258
-    protected function normalizeInputType($method)
259
-    {
260
-        if ('input' != $method) {
261
-            return;
262
-        }
263
-        $attributes = wp_parse_args($this->attributes, ['type' => '']);
264
-        if (!in_array($attributes['type'], static::INPUT_TYPES)) {
265
-            $this->attributes['type'] = 'text';
266
-        }
267
-    }
268
-
269
-    /**
270
-     * @return void
271
-     */
272
-    protected function removeEmptyAttributes()
273
-    {
274
-        $attributes = $this->attributes;
275
-        $permanentAttributes = $this->getPermanentAttributes();
276
-        foreach ($this->attributes as $key => $value) {
277
-            if (in_array($key, static::BOOLEAN_ATTRIBUTES) && !$value) {
278
-                unset($attributes[$key]);
279
-            }
280
-            if (Str::startsWith('data-', $key)) {
281
-                $permanentAttributes[$key] = $value;
282
-                unset($attributes[$key]);
283
-            }
284
-        }
285
-        $this->attributes = array_merge(array_filter($attributes), $permanentAttributes);
286
-    }
287
-
288
-    /**
289
-     * @return void
290
-     */
291
-    protected function removeIndexedAttributes()
292
-    {
293
-        $this->attributes = array_diff_key(
294
-            $this->attributes,
295
-            array_filter($this->attributes, 'is_numeric', ARRAY_FILTER_USE_KEY)
296
-        );
297
-    }
10
+	const ATTRIBUTES_A = [
11
+		'download', 'href', 'hreflang', 'ping', 'referrerpolicy', 'rel', 'target', 'type',
12
+	];
13
+
14
+	const ATTRIBUTES_BUTTON = [
15
+		'autofocus', 'disabled', 'form', 'formaction', 'formenctype', 'formmethod',
16
+		'formnovalidate', 'formtarget', 'name', 'type', 'value',
17
+	];
18
+
19
+	const ATTRIBUTES_FORM = [
20
+		'accept', 'accept-charset', 'action', 'autocapitalize', 'autocomplete', 'enctype', 'method',
21
+		'name', 'novalidate', 'target',
22
+	];
23
+
24
+	const ATTRIBUTES_IMG = [
25
+		'alt', 'crossorigin', 'decoding', 'height', 'ismap', 'loading', 'referrerpolicy', 'sizes', 
26
+		'src', 'srcset', 'width', 'usemap',
27
+	];
28
+
29
+	const ATTRIBUTES_INPUT = [
30
+		'accept', 'autocomplete', 'autocorrect', 'autofocus', 'capture', 'checked', 'disabled',
31
+		'form', 'formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget', 'height',
32
+		'incremental', 'inputmode', 'list', 'max', 'maxlength', 'min', 'minlength', 'multiple',
33
+		'name', 'pattern', 'placeholder', 'readonly', 'results', 'required', 'selectionDirection',
34
+		'selectionEnd', 'selectionStart', 'size', 'spellcheck', 'src', 'step', 'tabindex', 'type',
35
+		'value', 'webkitdirectory', 'width',
36
+	];
37
+
38
+	const ATTRIBUTES_LABEL = [
39
+		'for',
40
+	];
41
+
42
+	const ATTRIBUTES_OPTION = [
43
+		'disabled', 'label', 'selected', 'value',
44
+	];
45
+
46
+	const ATTRIBUTES_SELECT = [
47
+		'autofocus', 'disabled', 'form', 'multiple', 'name', 'required', 'size',
48
+	];
49
+
50
+	const ATTRIBUTES_TEXTAREA = [
51
+		'autocapitalize', 'autocomplete', 'autofocus', 'cols', 'disabled', 'form', 'maxlength',
52
+		'minlength', 'name', 'placeholder', 'readonly', 'required', 'rows', 'spellcheck', 'wrap',
53
+	];
54
+
55
+	const BOOLEAN_ATTRIBUTES = [
56
+		'autofocus', 'capture', 'checked', 'disabled', 'draggable', 'formnovalidate', 'hidden',
57
+		'multiple', 'novalidate', 'readonly', 'required', 'selected', 'spellcheck',
58
+		'webkitdirectory',
59
+	];
60
+
61
+	const GLOBAL_ATTRIBUTES = [
62
+		'accesskey', 'class', 'contenteditable', 'contextmenu', 'dir', 'draggable', 'dropzone',
63
+		'hidden', 'id', 'lang', 'spellcheck', 'style', 'tabindex', 'title',
64
+	];
65
+
66
+	const GLOBAL_WILDCARD_ATTRIBUTES = [
67
+		'aria-', 'data-', 'item', 'on',
68
+	];
69
+
70
+	const INPUT_TYPES = [
71
+		'button', 'checkbox', 'color', 'date', 'datetime-local', 'email', 'file', 'hidden', 'image',
72
+		'month', 'number', 'password', 'radio', 'range', 'reset', 'search', 'submit', 'tel', 'text',
73
+		'time', 'url', 'week',
74
+	];
75
+
76
+	/**
77
+	 * @var array
78
+	 */
79
+	protected $attributes = [];
80
+
81
+	/**
82
+	 * @param string $method
83
+	 * @param array $args
84
+	 * @return static
85
+	 */
86
+	public function __call($method, $args)
87
+	{
88
+		$constant = 'static::ATTRIBUTES_'.strtoupper($method);
89
+		$allowedAttributeKeys = defined($constant)
90
+			? constant($constant)
91
+			: [];
92
+		$this->normalize(Arr::consolidate(Arr::get($args, 0)), $allowedAttributeKeys);
93
+		$this->normalizeInputType($method);
94
+		return $this;
95
+	}
96
+
97
+	/**
98
+	 * @return static
99
+	 */
100
+	public function set(array $attributes)
101
+	{
102
+		$this->normalize($attributes);
103
+		return $this;
104
+	}
105
+
106
+	/**
107
+	 * @return array
108
+	 */
109
+	public function toArray()
110
+	{
111
+		return $this->attributes;
112
+	}
113
+
114
+	/**
115
+	 * @return string
116
+	 */
117
+	public function toString()
118
+	{
119
+		$attributes = [];
120
+		foreach ($this->attributes as $attribute => $value) {
121
+			$quote = $this->getQuoteChar($attribute);
122
+			$attributes[] = in_array($attribute, static::BOOLEAN_ATTRIBUTES)
123
+				? $attribute
124
+				: $attribute.'='.$quote.implode(',', (array) $value).$quote;
125
+		}
126
+		return implode(' ', $attributes);
127
+	}
128
+
129
+	/**
130
+	 * @return array
131
+	 */
132
+	protected function filterAttributes(array $allowedAttributeKeys)
133
+	{
134
+		return array_intersect_key($this->attributes, array_flip($allowedAttributeKeys));
135
+	}
136
+
137
+	/**
138
+	 * @return array
139
+	 */
140
+	protected function filterGlobalAttributes()
141
+	{
142
+		$globalAttributes = $this->filterAttributes(static::GLOBAL_ATTRIBUTES);
143
+		$wildcards = [];
144
+		foreach (static::GLOBAL_WILDCARD_ATTRIBUTES as $wildcard) {
145
+			$newWildcards = array_filter($this->attributes, function ($key) use ($wildcard) {
146
+				return Str::startsWith($wildcard, $key);
147
+			}, ARRAY_FILTER_USE_KEY);
148
+			$wildcards = array_merge($wildcards, $newWildcards);
149
+		}
150
+		return array_merge($globalAttributes, $wildcards);
151
+	}
152
+
153
+	/**
154
+	 * @return array
155
+	 */
156
+	protected function getPermanentAttributes()
157
+	{
158
+		$permanentAttributes = [];
159
+		if (array_key_exists('value', $this->attributes)) {
160
+			$permanentAttributes['value'] = $this->attributes['value'];
161
+		}
162
+		return $permanentAttributes;
163
+	}
164
+
165
+	/**
166
+	 * @param string $attribute
167
+	 * @return string
168
+	 */
169
+	protected function getQuoteChar($attribute)
170
+	{
171
+		return Str::startsWith('data-', $attribute)
172
+			? '\''
173
+			: '"';
174
+	}
175
+
176
+	/**
177
+	 * @param string $key
178
+	 * @param mixed $value
179
+	 * @return bool
180
+	 */
181
+	protected function isAttributeKeyNumeric($key, $value)
182
+	{
183
+		return is_string($value)
184
+			&& is_numeric($key)
185
+			&& !array_key_exists($value, $this->attributes);
186
+	}
187
+
188
+	/**
189
+	 * @return void
190
+	 */
191
+	protected function normalize(array $args, array $allowedAttributeKeys = [])
192
+	{
193
+		$this->attributes = array_change_key_case($args, CASE_LOWER);
194
+		$this->normalizeBooleanAttributes();
195
+		$this->normalizeDataAttributes();
196
+		$this->normalizeStringAttributes();
197
+		$this->removeEmptyAttributes();
198
+		$this->removeIndexedAttributes();
199
+		$this->attributes = array_merge(
200
+			$this->filterGlobalAttributes(),
201
+			$this->filterAttributes($allowedAttributeKeys)
202
+		);
203
+	}
204
+
205
+	/**
206
+	 * @return void
207
+	 */
208
+	protected function normalizeBooleanAttributes()
209
+	{
210
+		foreach ($this->attributes as $key => $value) {
211
+			if ($this->isAttributeKeyNumeric($key, $value)) {
212
+				$key = $value;
213
+				$value = true;
214
+			}
215
+			if (!in_array($key, static::BOOLEAN_ATTRIBUTES)) {
216
+				continue;
217
+			}
218
+			$this->attributes[$key] = wp_validate_boolean($value);
219
+		}
220
+	}
221
+
222
+	/**
223
+	 * @return void
224
+	 */
225
+	protected function normalizeDataAttributes()
226
+	{
227
+		foreach ($this->attributes as $key => $value) {
228
+			if ($this->isAttributeKeyNumeric($key, $value)) {
229
+				$key = $value;
230
+				$value = '';
231
+			}
232
+			if (!Str::startsWith('data-', $key)) {
233
+				continue;
234
+			}
235
+			if (is_array($value)) {
236
+				$value = json_encode($value, JSON_HEX_APOS | JSON_NUMERIC_CHECK | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
237
+			}
238
+			$this->attributes[$key] = $value;
239
+		}
240
+	}
241
+
242
+	/**
243
+	 * @return void
244
+	 */
245
+	protected function normalizeStringAttributes()
246
+	{
247
+		foreach ($this->attributes as $key => $value) {
248
+			if (is_string($value)) {
249
+				$this->attributes[$key] = trim($value);
250
+			}
251
+		}
252
+	}
253
+
254
+	/**
255
+	 * @param string $method
256
+	 * @return void
257
+	 */
258
+	protected function normalizeInputType($method)
259
+	{
260
+		if ('input' != $method) {
261
+			return;
262
+		}
263
+		$attributes = wp_parse_args($this->attributes, ['type' => '']);
264
+		if (!in_array($attributes['type'], static::INPUT_TYPES)) {
265
+			$this->attributes['type'] = 'text';
266
+		}
267
+	}
268
+
269
+	/**
270
+	 * @return void
271
+	 */
272
+	protected function removeEmptyAttributes()
273
+	{
274
+		$attributes = $this->attributes;
275
+		$permanentAttributes = $this->getPermanentAttributes();
276
+		foreach ($this->attributes as $key => $value) {
277
+			if (in_array($key, static::BOOLEAN_ATTRIBUTES) && !$value) {
278
+				unset($attributes[$key]);
279
+			}
280
+			if (Str::startsWith('data-', $key)) {
281
+				$permanentAttributes[$key] = $value;
282
+				unset($attributes[$key]);
283
+			}
284
+		}
285
+		$this->attributes = array_merge(array_filter($attributes), $permanentAttributes);
286
+	}
287
+
288
+	/**
289
+	 * @return void
290
+	 */
291
+	protected function removeIndexedAttributes()
292
+	{
293
+		$this->attributes = array_diff_key(
294
+			$this->attributes,
295
+			array_filter($this->attributes, 'is_numeric', ARRAY_FILTER_USE_KEY)
296
+		);
297
+	}
298 298
 }
Please login to merge, or discard this patch.
plugin/Database/SqlSchema.php 1 patch
Indentation   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -6,179 +6,179 @@  discard block
 block discarded – undo
6 6
 
7 7
 class SqlSchema
8 8
 {
9
-    protected $constraints;
10
-    protected $db;
11
-    protected $tables;
12
-
13
-    public function __construct()
14
-    {
15
-        require_once ABSPATH.'wp-admin/includes/upgrade.php';
16
-        global $wpdb;
17
-        $this->db = $wpdb;
18
-    }
19
-
20
-    /**
21
-     * @return void
22
-     */
23
-    public function addAssignedPostsTableConstraints()
24
-    {
25
-        if (!$this->tableConstraintExists($constraint = $this->prefix('assigned_posts').'_rating_id_foreign')) {
26
-            $this->db->query("
9
+	protected $constraints;
10
+	protected $db;
11
+	protected $tables;
12
+
13
+	public function __construct()
14
+	{
15
+		require_once ABSPATH.'wp-admin/includes/upgrade.php';
16
+		global $wpdb;
17
+		$this->db = $wpdb;
18
+	}
19
+
20
+	/**
21
+	 * @return void
22
+	 */
23
+	public function addAssignedPostsTableConstraints()
24
+	{
25
+		if (!$this->tableConstraintExists($constraint = $this->prefix('assigned_posts').'_rating_id_foreign')) {
26
+			$this->db->query("
27 27
                 ALTER TABLE {$this->table('assigned_posts')}
28 28
                 ADD CONSTRAINT {$constraint}
29 29
                 FOREIGN KEY (rating_id)
30 30
                 REFERENCES {$this->table('ratings')} (ID)
31 31
                 ON DELETE CASCADE
32 32
             ");
33
-        }
34
-        if (!$this->tableConstraintExists($constraint = $this->prefix('assigned_posts').'_post_id_foreign')) {
35
-            $this->db->query("
33
+		}
34
+		if (!$this->tableConstraintExists($constraint = $this->prefix('assigned_posts').'_post_id_foreign')) {
35
+			$this->db->query("
36 36
                 ALTER TABLE {$this->table('assigned_posts')}
37 37
                 ADD CONSTRAINT {$constraint}
38 38
                 FOREIGN KEY (post_id)
39 39
                 REFERENCES {$this->db->posts} (ID)
40 40
                 ON DELETE CASCADE
41 41
             ");
42
-        }
43
-    }
44
-
45
-    /**
46
-     * @return void
47
-     */
48
-    public function addAssignedTermsTableConstraints()
49
-    {
50
-        if (!$this->tableConstraintExists($constraint = $this->prefix('assigned_terms').'_rating_id_foreign')) {
51
-            $this->db->query("
42
+		}
43
+	}
44
+
45
+	/**
46
+	 * @return void
47
+	 */
48
+	public function addAssignedTermsTableConstraints()
49
+	{
50
+		if (!$this->tableConstraintExists($constraint = $this->prefix('assigned_terms').'_rating_id_foreign')) {
51
+			$this->db->query("
52 52
                 ALTER TABLE {$this->table('assigned_terms')}
53 53
                 ADD CONSTRAINT {$constraint}
54 54
                 FOREIGN KEY (rating_id)
55 55
                 REFERENCES {$this->table('ratings')} (ID)
56 56
                 ON DELETE CASCADE
57 57
             ");
58
-        }
59
-        if (!$this->tableConstraintExists($constraint = $this->prefix('assigned_terms').'_term_id_foreign')) {
60
-            $this->db->query("
58
+		}
59
+		if (!$this->tableConstraintExists($constraint = $this->prefix('assigned_terms').'_term_id_foreign')) {
60
+			$this->db->query("
61 61
                 ALTER TABLE {$this->table('assigned_terms')}
62 62
                 ADD CONSTRAINT {$constraint}
63 63
                 FOREIGN KEY (term_id)
64 64
                 REFERENCES {$this->db->terms} (term_id)
65 65
                 ON DELETE CASCADE
66 66
             ");
67
-        }
68
-    }
69
-
70
-    /**
71
-     * @return void
72
-     */
73
-    public function addAssignedUsersTableConstraints()
74
-    {
75
-        if (!$this->tableConstraintExists($constraint = $this->prefix('assigned_users').'_rating_id_foreign')) {
76
-            $this->db->query("
67
+		}
68
+	}
69
+
70
+	/**
71
+	 * @return void
72
+	 */
73
+	public function addAssignedUsersTableConstraints()
74
+	{
75
+		if (!$this->tableConstraintExists($constraint = $this->prefix('assigned_users').'_rating_id_foreign')) {
76
+			$this->db->query("
77 77
                 ALTER TABLE {$this->table('assigned_users')}
78 78
                 ADD CONSTRAINT {$constraint}
79 79
                 FOREIGN KEY (rating_id)
80 80
                 REFERENCES {$this->table('ratings')} (ID)
81 81
                 ON DELETE CASCADE
82 82
             ");
83
-        }
84
-        if (!$this->tableConstraintExists($constraint = $this->prefix('assigned_users').'_user_id_foreign')) {
85
-            $this->db->query("
83
+		}
84
+		if (!$this->tableConstraintExists($constraint = $this->prefix('assigned_users').'_user_id_foreign')) {
85
+			$this->db->query("
86 86
                 ALTER TABLE {$this->table('assigned_users')}
87 87
                 ADD CONSTRAINT {$constraint}
88 88
                 FOREIGN KEY (user_id)
89 89
                 REFERENCES {$this->db->users} (ID)
90 90
                 ON DELETE CASCADE
91 91
             ");
92
-        }
93
-    }
94
-
95
-    /**
96
-     * @return void
97
-     */
98
-    public function addReviewsTableConstraints()
99
-    {
100
-        if (!$this->tableConstraintExists($constraint = $this->prefix('assigned_posts').'_review_id_foreign')) {
101
-            $this->db->query("
92
+		}
93
+	}
94
+
95
+	/**
96
+	 * @return void
97
+	 */
98
+	public function addReviewsTableConstraints()
99
+	{
100
+		if (!$this->tableConstraintExists($constraint = $this->prefix('assigned_posts').'_review_id_foreign')) {
101
+			$this->db->query("
102 102
                 ALTER TABLE {$this->table('ratings')}
103 103
                 ADD CONSTRAINT {$constraint}
104 104
                 FOREIGN KEY (review_id)
105 105
                 REFERENCES {$this->db->posts} (ID)
106 106
                 ON DELETE CASCADE
107 107
             ");
108
-        }
109
-    }
110
-
111
-    /**
112
-     * @return void
113
-     */
114
-    public function addTableConstraints()
115
-    {
116
-        if (!defined('GLSR_UNIT_TESTS')) {
117
-            $this->addAssignedPostsTableConstraints();
118
-            $this->addAssignedTermsTableConstraints();
119
-            $this->addAssignedUsersTableConstraints();
120
-            $this->addReviewsTableConstraints();
121
-        }
122
-    }
123
-
124
-    /**
125
-     * @return bool
126
-     */
127
-    public function createAssignedPostsTable()
128
-    {
129
-        if ($this->tableExists('assigned_posts')) {
130
-            return false;
131
-        }
132
-        dbDelta("CREATE TABLE {$this->table('assigned_posts')} (
108
+		}
109
+	}
110
+
111
+	/**
112
+	 * @return void
113
+	 */
114
+	public function addTableConstraints()
115
+	{
116
+		if (!defined('GLSR_UNIT_TESTS')) {
117
+			$this->addAssignedPostsTableConstraints();
118
+			$this->addAssignedTermsTableConstraints();
119
+			$this->addAssignedUsersTableConstraints();
120
+			$this->addReviewsTableConstraints();
121
+		}
122
+	}
123
+
124
+	/**
125
+	 * @return bool
126
+	 */
127
+	public function createAssignedPostsTable()
128
+	{
129
+		if ($this->tableExists('assigned_posts')) {
130
+			return false;
131
+		}
132
+		dbDelta("CREATE TABLE {$this->table('assigned_posts')} (
133 133
             rating_id bigint(20) unsigned NOT NULL,
134 134
             post_id bigint(20) unsigned NOT NULL,
135 135
             is_published tinyint(1) NOT NULL DEFAULT '1',
136 136
             UNIQUE KEY {$this->prefix('assigned_posts')}_rating_id_post_id_unique (rating_id,post_id)
137 137
         ) {$this->db->get_charset_collate()};");
138
-        return true;
139
-    }
140
-
141
-    /**
142
-     * @return bool
143
-     */
144
-    public function createAssignedTermsTable()
145
-    {
146
-        if ($this->tableExists('assigned_terms')) {
147
-            return false;
148
-        }
149
-        dbDelta("CREATE TABLE {$this->table('assigned_terms')} (
138
+		return true;
139
+	}
140
+
141
+	/**
142
+	 * @return bool
143
+	 */
144
+	public function createAssignedTermsTable()
145
+	{
146
+		if ($this->tableExists('assigned_terms')) {
147
+			return false;
148
+		}
149
+		dbDelta("CREATE TABLE {$this->table('assigned_terms')} (
150 150
             rating_id bigint(20) unsigned NOT NULL,
151 151
             term_id bigint(20) unsigned NOT NULL,
152 152
             UNIQUE KEY {$this->prefix('assigned_terms')}_rating_id_term_id_unique (rating_id,term_id)
153 153
         ) {$this->db->get_charset_collate()};");
154
-        return true;
155
-    }
156
-
157
-    /**
158
-     * @return bool
159
-     */
160
-    public function createAssignedUsersTable()
161
-    {
162
-        if ($this->tableExists('assigned_users')) {
163
-            return false;
164
-        }
165
-        dbDelta("CREATE TABLE {$this->table('assigned_users')} (
154
+		return true;
155
+	}
156
+
157
+	/**
158
+	 * @return bool
159
+	 */
160
+	public function createAssignedUsersTable()
161
+	{
162
+		if ($this->tableExists('assigned_users')) {
163
+			return false;
164
+		}
165
+		dbDelta("CREATE TABLE {$this->table('assigned_users')} (
166 166
             rating_id bigint(20) unsigned NOT NULL,
167 167
             user_id bigint(20) unsigned NOT NULL,
168 168
             UNIQUE KEY {$this->prefix('assigned_users')}_rating_id_user_id_unique (rating_id,user_id)
169 169
         ) {$this->db->get_charset_collate()};");
170
-        return true;
171
-    }
172
-
173
-    /**
174
-     * @return bool
175
-     */
176
-    public function createRatingTable()
177
-    {
178
-        if ($this->tableExists('ratings')) {
179
-            return false;
180
-        }
181
-        dbDelta("CREATE TABLE {$this->table('ratings')} (
170
+		return true;
171
+	}
172
+
173
+	/**
174
+	 * @return bool
175
+	 */
176
+	public function createRatingTable()
177
+	{
178
+		if ($this->tableExists('ratings')) {
179
+			return false;
180
+		}
181
+		dbDelta("CREATE TABLE {$this->table('ratings')} (
182 182
             ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
183 183
             review_id bigint(20) unsigned NOT NULL,
184 184
             rating int(11) NOT NULL DEFAULT '0',
@@ -194,61 +194,61 @@  discard block
 block discarded – undo
194 194
             UNIQUE KEY {$this->prefix('ratings')}_review_id_unique (review_id),
195 195
             KEY {$this->prefix('ratings')}_rating_type_is_pinned_index (rating,type,is_pinned)
196 196
         ) {$this->db->get_charset_collate()};");
197
-        return true;
198
-    }
199
-
200
-    /**
201
-     * @return void
202
-     */
203
-    public function createTables()
204
-    {
205
-        $this->createAssignedPostsTable();
206
-        $this->createAssignedTermsTable();
207
-        $this->createAssignedUsersTable();
208
-        $this->createRatingTable();
209
-    }
210
-
211
-    /**
212
-     * @return string
213
-     */
214
-    public function prefix($table)
215
-    {
216
-        return glsr()->prefix.$table;
217
-    }
218
-
219
-    /**
220
-     * @return string
221
-     */
222
-    public function table($table)
223
-    {
224
-        $prefix = $this->db->prefix.glsr()->prefix;
225
-        return !Str::startsWith($prefix, $table)
226
-            ? $prefix.$table
227
-            : $table;
228
-    }
229
-
230
-    /**
231
-     * @return bool
232
-     */
233
-    public function tableExists($table)
234
-    {
235
-        if (!isset($this->tables)) {
236
-            $prefix = $this->db->prefix.glsr()->prefix;
237
-            $this->tables = $this->db->get_col("SHOW TABLES LIKE '{$prefix}%'");
238
-        }
239
-        return in_array($this->table($table), $this->tables);
240
-    }
241
-
242
-    /**
243
-     * @return bool
244
-     */
245
-    public function tableConstraintExists($constraint)
246
-    {
247
-        if (!isset($this->constraints)) {
248
-            $this->constraints = $this->db->get_col("
197
+		return true;
198
+	}
199
+
200
+	/**
201
+	 * @return void
202
+	 */
203
+	public function createTables()
204
+	{
205
+		$this->createAssignedPostsTable();
206
+		$this->createAssignedTermsTable();
207
+		$this->createAssignedUsersTable();
208
+		$this->createRatingTable();
209
+	}
210
+
211
+	/**
212
+	 * @return string
213
+	 */
214
+	public function prefix($table)
215
+	{
216
+		return glsr()->prefix.$table;
217
+	}
218
+
219
+	/**
220
+	 * @return string
221
+	 */
222
+	public function table($table)
223
+	{
224
+		$prefix = $this->db->prefix.glsr()->prefix;
225
+		return !Str::startsWith($prefix, $table)
226
+			? $prefix.$table
227
+			: $table;
228
+	}
229
+
230
+	/**
231
+	 * @return bool
232
+	 */
233
+	public function tableExists($table)
234
+	{
235
+		if (!isset($this->tables)) {
236
+			$prefix = $this->db->prefix.glsr()->prefix;
237
+			$this->tables = $this->db->get_col("SHOW TABLES LIKE '{$prefix}%'");
238
+		}
239
+		return in_array($this->table($table), $this->tables);
240
+	}
241
+
242
+	/**
243
+	 * @return bool
244
+	 */
245
+	public function tableConstraintExists($constraint)
246
+	{
247
+		if (!isset($this->constraints)) {
248
+			$this->constraints = $this->db->get_col("
249 249
                 SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE CONSTRAINT_SCHEMA = '{$this->db->dbname}'
250 250
             ");
251
-        }
252
-        return in_array($constraint, $this->constraints);
253
-    }
251
+		}
252
+		return in_array($constraint, $this->constraints);
253
+	}
254 254
 }
Please login to merge, or discard this patch.