@@ -6,7 +6,6 @@ |
||
6 | 6 | use Ffcms\Core\Helper\HTML\System\NativeGenerator; |
7 | 7 | use Ffcms\Core\Helper\Type\Any; |
8 | 8 | use Ffcms\Core\Helper\Type\Arr; |
9 | -use Ffcms\Core\Helper\Type\Obj; |
|
10 | 9 | |
11 | 10 | /** |
12 | 11 | * Class MultiCheckboxField. Make multiple checkboxes form field |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | // check if options is defined |
44 | 44 | $options = $this->properties['options']; |
45 | 45 | if (!Any::isIterable($options)) |
46 | - throw new SyntaxException('Options for field ' . self::nohtml($this->name) . ' is not iterable'); |
|
46 | + throw new SyntaxException('Options for field '.self::nohtml($this->name).' is not iterable'); |
|
47 | 47 | |
48 | 48 | unset($this->properties['options']); |
49 | 49 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $this->properties['value'] = $opt; |
65 | 65 | // apply structured checkboxes style for each item |
66 | 66 | $build .= App::$View->render('native/form/multi_checkboxes_list', [ |
67 | - 'item' => self::buildSingleTag('input', $this->properties) . self::nohtml($opt) |
|
67 | + 'item' => self::buildSingleTag('input', $this->properties).self::nohtml($opt) |
|
68 | 68 | ]); |
69 | 69 | } |
70 | 70 |
@@ -42,8 +42,9 @@ |
||
42 | 42 | { |
43 | 43 | // check if options is defined |
44 | 44 | $options = $this->properties['options']; |
45 | - if (!Any::isIterable($options)) |
|
46 | - throw new SyntaxException('Options for field ' . self::nohtml($this->name) . ' is not iterable'); |
|
45 | + if (!Any::isIterable($options)) { |
|
46 | + throw new SyntaxException('Options for field ' . self::nohtml($this->name) . ' is not iterable'); |
|
47 | + } |
|
47 | 48 | |
48 | 49 | unset($this->properties['options']); |
49 | 50 |
@@ -5,7 +5,6 @@ |
||
5 | 5 | use Ffcms\Core\Helper\HTML\System\NativeGenerator; |
6 | 6 | use Ffcms\Core\Helper\Type\Any; |
7 | 7 | use Ffcms\Core\Helper\Type\Arr; |
8 | -use Ffcms\Core\Helper\Type\Obj; |
|
9 | 8 | |
10 | 9 | class MultiSelectField extends NativeGenerator implements iField |
11 | 10 | { |
@@ -37,7 +37,7 @@ |
||
37 | 37 | $options = $this->properties['options']; |
38 | 38 | $optionsKey = (bool)$this->properties['optionsKey']; |
39 | 39 | if (!Any::isIterable($options)) |
40 | - throw new SyntaxException('Options for field ' . self::nohtml($this->name) . ' is not iterable'); |
|
40 | + throw new SyntaxException('Options for field '.self::nohtml($this->name).' is not iterable'); |
|
41 | 41 | |
42 | 42 | unset($this->properties['options']); |
43 | 43 |
@@ -36,8 +36,9 @@ discard block |
||
36 | 36 | // check if options is defined |
37 | 37 | $options = $this->properties['options']; |
38 | 38 | $optionsKey = (bool)$this->properties['optionsKey']; |
39 | - if (!Any::isIterable($options)) |
|
40 | - throw new SyntaxException('Options for field ' . self::nohtml($this->name) . ' is not iterable'); |
|
39 | + if (!Any::isIterable($options)) { |
|
40 | + throw new SyntaxException('Options for field ' . self::nohtml($this->name) . ' is not iterable'); |
|
41 | + } |
|
41 | 42 | |
42 | 43 | unset($this->properties['options']); |
43 | 44 | |
@@ -56,11 +57,13 @@ discard block |
||
56 | 57 | if ($optionsKey === true) { |
57 | 58 | $optionProperty['value'] = $val; |
58 | 59 | // check if current element is active |
59 | - if (Any::isArray($this->value) && Arr::in((string)$val, $this->value)) |
|
60 | - $optionProperty['selected'] = 'selected'; |
|
60 | + if (Any::isArray($this->value) && Arr::in((string)$val, $this->value)) { |
|
61 | + $optionProperty['selected'] = 'selected'; |
|
62 | + } |
|
61 | 63 | } else { |
62 | - if (Any::isArray($this->value) && Arr::in((string)$text, $this->value)) |
|
63 | - $optionProperty['selected'] = 'selected'; |
|
64 | + if (Any::isArray($this->value) && Arr::in((string)$text, $this->value)) { |
|
65 | + $optionProperty['selected'] = 'selected'; |
|
66 | + } |
|
64 | 67 | } |
65 | 68 | $optionsDOM .= self::buildContainerTag('option', $optionProperty, $text); |
66 | 69 | } |
@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use Ffcms\Core\Helper\Type\Any; |
6 | 6 | use Ffcms\Core\Helper\Type\Arr; |
7 | -use Ffcms\Core\Helper\Type\Obj; |
|
8 | 7 | |
9 | 8 | /** |
10 | 9 | * Class SimplePagination. Build and display html pagination block |
@@ -37,17 +37,20 @@ discard block |
||
37 | 37 | public function display(array $property = null): ?string |
38 | 38 | { |
39 | 39 | // total items is less to pagination requirement |
40 | - if (($this->page * $this->step) + 1 > $this->total) |
|
41 | - return null; |
|
40 | + if (($this->page * $this->step) + 1 > $this->total) { |
|
41 | + return null; |
|
42 | + } |
|
42 | 43 | |
43 | 44 | $lastPage = ceil($this->total / $this->step); // 6/5 ~ 2 = 0..2 |
44 | 45 | |
45 | - if ($lastPage <= 1) |
|
46 | - return null; |
|
46 | + if ($lastPage <= 1) { |
|
47 | + return null; |
|
48 | + } |
|
47 | 49 | |
48 | 50 | // prevent hack-boy's any try |
49 | - if ($this->page > $lastPage) |
|
50 | - return null; |
|
51 | + if ($this->page > $lastPage) { |
|
52 | + return null; |
|
53 | + } |
|
51 | 54 | |
52 | 55 | $items = []; |
53 | 56 | // more then 10 items in pagination |
@@ -137,8 +140,9 @@ discard block |
||
137 | 140 | protected function generateItems($start, $end) |
138 | 141 | { |
139 | 142 | // prevent any shit's |
140 | - if ($end <= $start) |
|
141 | - return null; |
|
143 | + if ($end <= $start) { |
|
144 | + return null; |
|
145 | + } |
|
142 | 146 | |
143 | 147 | $items = []; |
144 | 148 | for ($i = $start; $i < $end; $i++) { |
@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use Ffcms\Core\App; |
6 | 6 | use Ffcms\Core\Helper\Type\Any; |
7 | -use Ffcms\Core\Helper\Type\Obj; |
|
8 | 7 | use Ffcms\Core\Helper\Type\Str; |
9 | 8 | use Ffcms\Core\Helper\Url; |
10 | 9 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | $purifier = App::$Memory->get('object.purifier.helpers'); |
25 | 25 | } else { |
26 | 26 | $config = \HTMLPurifier_Config::createDefault(); |
27 | - $config->set('Cache.SerializerPath', root . '/Private/Cache/HTMLPurifier/'); |
|
27 | + $config->set('Cache.SerializerPath', root.'/Private/Cache/HTMLPurifier/'); |
|
28 | 28 | $config->set('AutoFormat.AutoParagraph', false); |
29 | 29 | |
30 | 30 | // allow use target=_blank for links |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | $build = null; |
66 | 66 | foreach ($property as $p => $v) { |
67 | 67 | if ($v === null || $v === false || $v === true) { |
68 | - $build .= ' ' . self::nohtml($p); |
|
68 | + $build .= ' '.self::nohtml($p); |
|
69 | 69 | } else { |
70 | - $build .= ' ' . self::nohtml($p) . '="' . self::nohtml($v) . '"'; |
|
70 | + $build .= ' '.self::nohtml($p).'="'.self::nohtml($v).'"'; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | return $build; |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public static function buildSingleTag($tagName, array $property = null, $closeSlash = true) |
84 | 84 | { |
85 | - return '<' . self::nohtml($tagName) . self::applyProperty($property) . ($closeSlash ? '/>' : '>'); |
|
85 | + return '<'.self::nohtml($tagName).self::applyProperty($property).($closeSlash ? '/>' : '>'); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | if ($valueHtml !== true) |
100 | 100 | $value = self::nohtml($value); |
101 | 101 | |
102 | - return '<' . $tagName . self::applyProperty($property) . '>' . $value . '</' . $tagName . '>'; |
|
102 | + return '<'.$tagName.self::applyProperty($property).'>'.$value.'</'.$tagName.'>'; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -140,13 +140,13 @@ discard block |
||
140 | 140 | if (!Str::contains('/', $elementPoint) || count($elementArray) < 2) { |
141 | 141 | $active = $elementPoint === $currentPoint; |
142 | 142 | } else { |
143 | - $elementPoint = $elementArray[0] . '/' . $elementArray[1]; |
|
143 | + $elementPoint = $elementArray[0].'/'.$elementArray[1]; |
|
144 | 144 | $active = Str::startsWith($elementPoint, $currentPoint); |
145 | 145 | } |
146 | 146 | break; |
147 | 147 | case 'id': |
148 | 148 | $elementArray = explode('/', $elementPoint); |
149 | - $elementPoint = $elementArray[0] . '/' . $elementArray[1]; |
|
149 | + $elementPoint = $elementArray[0].'/'.$elementArray[1]; |
|
150 | 150 | if ($elementArray[2] === null) { // looks like id is not defined in element |
151 | 151 | if (Str::contains('?', $currentPoint)) { |
152 | 152 | $currentPoint = Str::firstIn($currentPoint, '?'); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $currentToId = implode('/', array_slice($currentArray, 0, 3)); |
156 | 156 | $active = $elementPoint === $currentToId; |
157 | 157 | } else { |
158 | - $elementPoint .= '/' . $elementArray[2]; |
|
158 | + $elementPoint .= '/'.$elementArray[2]; |
|
159 | 159 | $active = Str::startsWith($elementPoint, $currentPoint); |
160 | 160 | } |
161 | 161 | break; |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | */ |
211 | 211 | public static function convertLink($uri) |
212 | 212 | { |
213 | - $link = App::$Alias->baseUrl . '/'; |
|
213 | + $link = App::$Alias->baseUrl.'/'; |
|
214 | 214 | if (Any::isArray($uri)) { |
215 | 215 | $link .= Url::buildPathway($uri); |
216 | 216 | } elseif (Str::startsWith('http', $uri)) { |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | if (Str::likeEmpty($uri)) |
234 | 234 | return null; |
235 | 235 | |
236 | - return implode('/', array_map(function($v){ |
|
236 | + return implode('/', array_map(function($v) { |
|
237 | 237 | return urlencode($v); |
238 | 238 | }, explode('/', $uri))); |
239 | 239 | } |
@@ -59,8 +59,9 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public static function applyProperty(array $property = null) |
61 | 61 | { |
62 | - if ($property === null || count($property) < 1) |
|
63 | - return null; |
|
62 | + if ($property === null || count($property) < 1) { |
|
63 | + return null; |
|
64 | + } |
|
64 | 65 | |
65 | 66 | $build = null; |
66 | 67 | foreach ($property as $p => $v) { |
@@ -96,8 +97,9 @@ discard block |
||
96 | 97 | public static function buildContainerTag($tagName, array $property = null, $value = null, $valueHtml = false) |
97 | 98 | { |
98 | 99 | $tagName = self::nohtml($tagName); |
99 | - if ($valueHtml !== true) |
|
100 | - $value = self::nohtml($value); |
|
100 | + if ($valueHtml !== true) { |
|
101 | + $value = self::nohtml($value); |
|
102 | + } |
|
101 | 103 | |
102 | 104 | return '<' . $tagName . self::applyProperty($property) . '>' . $value . '</' . $tagName . '>'; |
103 | 105 | } |
@@ -111,8 +113,9 @@ discard block |
||
111 | 113 | public static function safeUri($string, $encode = true) |
112 | 114 | { |
113 | 115 | $string = self::nohtml($string); |
114 | - if ($encode === true) |
|
115 | - $string = self::encode($string); |
|
116 | + if ($encode === true) { |
|
117 | + $string = self::encode($string); |
|
118 | + } |
|
116 | 119 | |
117 | 120 | return $string; |
118 | 121 | } |
@@ -230,8 +233,9 @@ discard block |
||
230 | 233 | */ |
231 | 234 | public static function encode(?string $uri = null) |
232 | 235 | { |
233 | - if (Str::likeEmpty($uri)) |
|
234 | - return null; |
|
236 | + if (Str::likeEmpty($uri)) { |
|
237 | + return null; |
|
238 | + } |
|
235 | 239 | |
236 | 240 | return implode('/', array_map(function($v){ |
237 | 241 | return urlencode($v); |
@@ -7,7 +7,6 @@ |
||
7 | 7 | use Ffcms\Core\Helper\HTML\System\NativeGenerator; |
8 | 8 | use Ffcms\Core\Helper\Type\Any; |
9 | 9 | use Ffcms\Core\Helper\Type\Arr; |
10 | -use Ffcms\Core\Helper\Type\Obj; |
|
11 | 10 | |
12 | 11 | /** |
13 | 12 | * Class Table. Helper for drawing tables using php static call Table::display([params]) |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | // init dom model |
36 | 36 | $dom = new Dom(); |
37 | 37 | // draw response |
38 | - $table = $dom->table(function () use ($dom, $elements, $selectOptions) { |
|
38 | + $table = $dom->table(function() use ($dom, $elements, $selectOptions) { |
|
39 | 39 | $res = null; |
40 | 40 | // check if thead is defined |
41 | 41 | if (isset($elements['thead']) && Any::isArray($elements['thead']) && count($elements['thead']) > 0 && Any::isArray($elements['thead']['titles'])) { |
42 | 42 | // add thead container |
43 | - $res .= $dom->thead(function () use ($dom, $elements, $selectOptions) { |
|
44 | - return $dom->tr(function () use ($dom, $elements, $selectOptions) { |
|
43 | + $res .= $dom->thead(function() use ($dom, $elements, $selectOptions) { |
|
44 | + return $dom->tr(function() use ($dom, $elements, $selectOptions) { |
|
45 | 45 | $tr = null; |
46 | 46 | foreach ($elements['thead']['titles'] as $order => $title) { |
47 | 47 | $th = null; |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | } |
57 | 57 | // make global checkbox for selectable columns |
58 | 58 | if ($selectOptions !== false && $order + 1 === $selectOptions['attachOrder']) { |
59 | - $th = $dom->input(function () { |
|
59 | + $th = $dom->input(function() { |
|
60 | 60 | return null; |
61 | - }, ['type' => 'checkbox', 'name' => 'selectAll']) . ' ' . $th; |
|
61 | + }, ['type' => 'checkbox', 'name' => 'selectAll']).' '.$th; |
|
62 | 62 | } |
63 | 63 | // build tr row collecting all th's |
64 | - $tr .= $dom->th(function () use ($th) { |
|
64 | + $tr .= $dom->th(function() use ($th) { |
|
65 | 65 | return $th; |
66 | 66 | }, $title['property']); |
67 | 67 | } |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | // sort td items inside row by key increment |
81 | 81 | ksort($row); |
82 | 82 | // add data in tr container |
83 | - $tr .= $dom->tr(function () use ($dom, $row, $selectOptions) { |
|
83 | + $tr .= $dom->tr(function() use ($dom, $row, $selectOptions) { |
|
84 | 84 | $td = null; |
85 | 85 | foreach ($row as $order => $item) { |
86 | 86 | if (!Any::isInt($order)) |
87 | 87 | continue; |
88 | 88 | |
89 | 89 | // collect td item |
90 | - $td .= $dom->td(function () use ($dom, $order, $item, $selectOptions) { |
|
90 | + $td .= $dom->td(function() use ($dom, $order, $item, $selectOptions) { |
|
91 | 91 | $text = null; |
92 | 92 | // make text secure based on passed options |
93 | 93 | if ($item['html'] === true) { |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | } |
102 | 102 | // check if selectable box is enabled and equal current order id |
103 | 103 | if ($selectOptions !== false && $order === $selectOptions['attachOrder']) { |
104 | - $text = $dom->input(function (){ |
|
104 | + $text = $dom->input(function() { |
|
105 | 105 | return null; |
106 | - }, Arr::merge($selectOptions['selector'], ['value' => htmlentities($text, null, 'UTF-8')])) . ' ' . $text; |
|
106 | + }, Arr::merge($selectOptions['selector'], ['value' => htmlentities($text, null, 'UTF-8')])).' '.$text; |
|
107 | 107 | } |
108 | 108 | return $text; |
109 | 109 | }, $item['property']); |
@@ -126,14 +126,14 @@ discard block |
||
126 | 126 | // build js code for "selectAll" checkbox |
127 | 127 | self::buildSelectorHtml($selectOptions); |
128 | 128 | // return response inside "form" tag |
129 | - return $dom->form(function () use ($dom, $selectOptions, $table) { |
|
129 | + return $dom->form(function() use ($dom, $selectOptions, $table) { |
|
130 | 130 | foreach ($selectOptions['buttons'] as $btn) { |
131 | 131 | if (!Any::isArray($btn)) |
132 | 132 | continue; |
133 | 133 | |
134 | - $table .= $dom->input(function(){ |
|
134 | + $table .= $dom->input(function() { |
|
135 | 135 | return null; |
136 | - }, $btn) . ' '; |
|
136 | + }, $btn).' '; |
|
137 | 137 | } |
138 | 138 | return $table; |
139 | 139 | }, $selectOptions['form']); |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | private static function buildSelectorHtml(array $opt) |
150 | 150 | { |
151 | 151 | $js = '$(function () { |
152 | - var targetSwitchbox = $(\'input[name="' . $opt['selector']['name'] . '"]\'); |
|
152 | + var targetSwitchbox = $(\'input[name="' . $opt['selector']['name'].'"]\'); |
|
153 | 153 | $(\'input[name="selectAll"]\').change(function() { |
154 | 154 | $(targetSwitchbox).each(function () { |
155 | 155 | $(this).prop(\'checked\', !$(this).is(\':checked\')); |
@@ -23,8 +23,9 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public static function display(array $elements): ?string |
25 | 25 | { |
26 | - if (!array_key_exists('tbody', $elements) || !Any::isArray($elements['tbody']['items']) || count($elements['tbody']['items']) < 1) |
|
27 | - return null; |
|
26 | + if (!array_key_exists('tbody', $elements) || !Any::isArray($elements['tbody']['items']) || count($elements['tbody']['items']) < 1) { |
|
27 | + return null; |
|
28 | + } |
|
28 | 29 | |
29 | 30 | $selectOptions = false; |
30 | 31 | if (isset($elements['selectableBox'])) { |
@@ -83,8 +84,9 @@ discard block |
||
83 | 84 | $tr .= $dom->tr(function () use ($dom, $row, $selectOptions) { |
84 | 85 | $td = null; |
85 | 86 | foreach ($row as $order => $item) { |
86 | - if (!Any::isInt($order)) |
|
87 | - continue; |
|
87 | + if (!Any::isInt($order)) { |
|
88 | + continue; |
|
89 | + } |
|
88 | 90 | |
89 | 91 | // collect td item |
90 | 92 | $td .= $dom->td(function () use ($dom, $order, $item, $selectOptions) { |
@@ -128,8 +130,9 @@ discard block |
||
128 | 130 | // return response inside "form" tag |
129 | 131 | return $dom->form(function () use ($dom, $selectOptions, $table) { |
130 | 132 | foreach ($selectOptions['buttons'] as $btn) { |
131 | - if (!Any::isArray($btn)) |
|
132 | - continue; |
|
133 | + if (!Any::isArray($btn)) { |
|
134 | + continue; |
|
135 | + } |
|
133 | 136 | |
134 | 137 | $table .= $dom->input(function(){ |
135 | 138 | return null; |
@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use Ffcms\Core\Helper\Type\Any; |
6 | 6 | use Ffcms\Core\Helper\Type\Arr; |
7 | -use Ffcms\Core\Helper\Type\Obj; |
|
8 | 7 | use Ffcms\Core\Helper\Type\Str; |
9 | 8 | |
10 | 9 | /** |
@@ -23,8 +23,9 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public static function length_min($object, $length): bool |
25 | 25 | { |
26 | - if (!Any::isLine($object)) |
|
27 | - return false; |
|
26 | + if (!Any::isLine($object)) { |
|
27 | + return false; |
|
28 | + } |
|
28 | 29 | |
29 | 30 | return Str::length((string)$object) >= $length; |
30 | 31 | } |
@@ -37,8 +38,9 @@ discard block |
||
37 | 38 | */ |
38 | 39 | public static function length_max($object, $length): bool |
39 | 40 | { |
40 | - if (!Any::isLine($object)) |
|
41 | - return false; |
|
41 | + if (!Any::isLine($object)) { |
|
42 | + return false; |
|
43 | + } |
|
42 | 44 | |
43 | 45 | return Str::length((string)$object) <= $length; |
44 | 46 | } |
@@ -51,12 +53,14 @@ discard block |
||
51 | 53 | */ |
52 | 54 | public static function in($object, array $handle): bool |
53 | 55 | { |
54 | - if (!Any::isLine($object)) |
|
55 | - return false; |
|
56 | + if (!Any::isLine($object)) { |
|
57 | + return false; |
|
58 | + } |
|
56 | 59 | |
57 | 60 | // allow empty, validate on required rule |
58 | - if (Any::isEmpty($object)) |
|
59 | - return true; |
|
61 | + if (Any::isEmpty($object)) { |
|
62 | + return true; |
|
63 | + } |
|
60 | 64 | |
61 | 65 | $object = Any::guessValueType($object); |
62 | 66 | |
@@ -81,8 +85,9 @@ discard block |
||
81 | 85 | */ |
82 | 86 | public static function checked($object): bool |
83 | 87 | { |
84 | - if (!Any::isBool($object)) |
|
85 | - return false; |
|
88 | + if (!Any::isBool($object)) { |
|
89 | + return false; |
|
90 | + } |
|
86 | 91 | |
87 | 92 | return (bool)$object; |
88 | 93 | } |
@@ -154,8 +159,9 @@ discard block |
||
154 | 159 | */ |
155 | 160 | public static function email($object): bool |
156 | 161 | { |
157 | - if (!Any::isLine($object)) |
|
158 | - return false; |
|
162 | + if (!Any::isLine($object)) { |
|
163 | + return false; |
|
164 | + } |
|
159 | 165 | |
160 | 166 | // @todo: check this sh@t |
161 | 167 | // allow empty, validate on required rule |
@@ -172,8 +178,9 @@ discard block |
||
172 | 178 | */ |
173 | 179 | public static function phone($object): bool |
174 | 180 | { |
175 | - if (!Any::isLine($object)) |
|
176 | - return false; |
|
181 | + if (!Any::isLine($object)) { |
|
182 | + return false; |
|
183 | + } |
|
177 | 184 | |
178 | 185 | // @todo: check it |
179 | 186 | // allow empty, validate on required rule |
@@ -191,8 +198,9 @@ discard block |
||
191 | 198 | */ |
192 | 199 | public static function url($object): bool |
193 | 200 | { |
194 | - if (!Any::isLine($object)) |
|
195 | - return false; |
|
201 | + if (!Any::isLine($object)) { |
|
202 | + return false; |
|
203 | + } |
|
196 | 204 | |
197 | 205 | // allow empty, validate on required rule |
198 | 206 | //if (Str::likeEmpty($object)) { |
@@ -210,8 +218,9 @@ discard block |
||
210 | 218 | */ |
211 | 219 | public static function equal($object, $value = null): bool |
212 | 220 | { |
213 | - if (!Any::isLine($object)) |
|
214 | - return false; |
|
221 | + if (!Any::isLine($object)) { |
|
222 | + return false; |
|
223 | + } |
|
215 | 224 | |
216 | 225 | return $object === $value; |
217 | 226 | } |
@@ -224,8 +233,9 @@ discard block |
||
224 | 233 | */ |
225 | 234 | public static function notequal($object, $value = null): bool |
226 | 235 | { |
227 | - if (Any::isLine($object)) |
|
228 | - return false; |
|
236 | + if (Any::isLine($object)) { |
|
237 | + return false; |
|
238 | + } |
|
229 | 239 | |
230 | 240 | return $object !== $value; |
231 | 241 | } |
@@ -260,11 +270,13 @@ discard block |
||
260 | 270 | */ |
261 | 271 | public static function reg_match($object, $value): bool |
262 | 272 | { |
263 | - if (!Any::isLine($object)) |
|
264 | - return false; |
|
273 | + if (!Any::isLine($object)) { |
|
274 | + return false; |
|
275 | + } |
|
265 | 276 | |
266 | - if (Str::likeEmpty($object)) |
|
267 | - return true; |
|
277 | + if (Str::likeEmpty($object)) { |
|
278 | + return true; |
|
279 | + } |
|
268 | 280 | |
269 | 281 | // what the f*ck? -> return preg_match($value, $object) > 0; |
270 | 282 | return (bool)preg_match($value, $object); |
@@ -278,8 +290,9 @@ discard block |
||
278 | 290 | */ |
279 | 291 | public static function intList($object, $value): bool |
280 | 292 | { |
281 | - if (!Any::isLine($object)) |
|
282 | - return false; |
|
293 | + if (!Any::isLine($object)) { |
|
294 | + return false; |
|
295 | + } |
|
283 | 296 | |
284 | 297 | return !preg_match('/[^0-9\s,]/$', $object); |
285 | 298 | } |
@@ -293,8 +306,9 @@ discard block |
||
293 | 306 | public static function isFile($object, $value): bool |
294 | 307 | { |
295 | 308 | // allow empty fields, "required" option filter that |
296 | - if ($object === null) |
|
297 | - return true; |
|
309 | + if ($object === null) { |
|
310 | + return true; |
|
311 | + } |
|
298 | 312 | |
299 | 313 | $all = false; |
300 | 314 | // if string is given |
@@ -307,13 +321,15 @@ discard block |
||
307 | 321 | } |
308 | 322 | |
309 | 323 | // input file is not object? |
310 | - if ($object === null || !Any::isObj($object)) |
|
311 | - return false; |
|
324 | + if ($object === null || !Any::isObj($object)) { |
|
325 | + return false; |
|
326 | + } |
|
312 | 327 | |
313 | 328 | // get guess file type, based on mime-type |
314 | 329 | $type = $object->guessExtension(); |
315 | - if ($type === null) |
|
316 | - return false; |
|
330 | + if ($type === null) { |
|
331 | + return false; |
|
332 | + } |
|
317 | 333 | |
318 | 334 | return ($all ? true : Arr::in($type, $value)); |
319 | 335 | } |
@@ -327,21 +343,24 @@ discard block |
||
327 | 343 | public static function sizeFile($object, $value): bool |
328 | 344 | { |
329 | 345 | // allow empty field, validate on filter 'required' |
330 | - if ($object === null) |
|
331 | - return true; |
|
346 | + if ($object === null) { |
|
347 | + return true; |
|
348 | + } |
|
332 | 349 | |
333 | 350 | if (!Any::isArray($value)) { |
334 | 351 | $value = [0, $value]; |
335 | 352 | } |
336 | 353 | |
337 | 354 | // input file is not object? |
338 | - if ($object === null || !Any::isObj($object)) |
|
339 | - return false; |
|
355 | + if ($object === null || !Any::isObj($object)) { |
|
356 | + return false; |
|
357 | + } |
|
340 | 358 | |
341 | 359 | // get file upload size in bytes |
342 | 360 | $realSize = $object->getClientSize(); |
343 | - if ($realSize === null) |
|
344 | - return false; |
|
361 | + if ($realSize === null) { |
|
362 | + return false; |
|
363 | + } |
|
345 | 364 | |
346 | 365 | return $realSize > $value[0] && $realSize <= $value[1]; |
347 | 366 | } |
@@ -9,7 +9,6 @@ |
||
9 | 9 | use Ffcms\Core\Helper\Serialize; |
10 | 10 | use Ffcms\Core\Helper\Type\Any; |
11 | 11 | use Ffcms\Core\Helper\Type\Arr; |
12 | -use Ffcms\Core\Helper\Type\Obj; |
|
13 | 12 | use Ffcms\Core\Helper\Type\Str; |
14 | 13 | |
15 | 14 | /** |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | if (Any::isArray($params) && count($params) > 0) { |
56 | 56 | foreach ($params as $var => $value) { |
57 | - $text = Str::replace('%' . $var . '%', $value, $text); |
|
57 | + $text = Str::replace('%'.$var.'%', $value, $text); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | return $text; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | public function translate(string $text, array $params = null) |
70 | 70 | { |
71 | 71 | $index = null; |
72 | - $namespace = 'Apps\Controller\\' . env_name . '\\'; |
|
72 | + $namespace = 'Apps\Controller\\'.env_name.'\\'; |
|
73 | 73 | foreach (@debug_backtrace() as $caller) { |
74 | 74 | if (isset($caller['class']) && Str::startsWith($namespace, $caller['class'])) { |
75 | 75 | $index = Str::sub((string)$caller['class'], Str::length($namespace)); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | protected function load(string $index): ?array |
87 | 87 | { |
88 | - $file = root . '/I18n/' . env_name . '/' . App::$Request->getLanguage() . '/' . $index . '.php'; |
|
88 | + $file = root.'/I18n/'.env_name.'/'.App::$Request->getLanguage().'/'.$index.'.php'; |
|
89 | 89 | if (!File::exist($file)) |
90 | 90 | return []; |
91 | 91 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | public function getAvailableLangs(): array |
122 | 122 | { |
123 | 123 | $langs = ['en']; |
124 | - $scan = Directory::scan(root . '/I18n/' . env_name . '/', GLOB_ONLYDIR, true); |
|
124 | + $scan = Directory::scan(root.'/I18n/'.env_name.'/', GLOB_ONLYDIR, true); |
|
125 | 125 | foreach ($scan as $row) { |
126 | 126 | $langs[] = trim($row, '/'); |
127 | 127 | } |
@@ -48,8 +48,9 @@ discard block |
||
48 | 48 | $this->indexes[] = $index; |
49 | 49 | } |
50 | 50 | |
51 | - if ($this->cached && Any::isStr($text) && isset($this->cached[$text])) |
|
52 | - $text = $this->cached[$text]; |
|
51 | + if ($this->cached && Any::isStr($text) && isset($this->cached[$text])) { |
|
52 | + $text = $this->cached[$text]; |
|
53 | + } |
|
53 | 54 | } |
54 | 55 | |
55 | 56 | if (Any::isArray($params) && count($params) > 0) { |
@@ -86,8 +87,9 @@ discard block |
||
86 | 87 | protected function load(string $index): ?array |
87 | 88 | { |
88 | 89 | $file = root . '/I18n/' . env_name . '/' . App::$Request->getLanguage() . '/' . $index . '.php'; |
89 | - if (!File::exist($file)) |
|
90 | - return []; |
|
90 | + if (!File::exist($file)) { |
|
91 | + return []; |
|
92 | + } |
|
91 | 93 | |
92 | 94 | return require($file); |
93 | 95 | } |
@@ -101,13 +103,15 @@ discard block |
||
101 | 103 | { |
102 | 104 | $path = Normalize::diskFullPath($path); |
103 | 105 | // check if file exist |
104 | - if (!File::exist($path)) |
|
105 | - return false; |
|
106 | + if (!File::exist($path)) { |
|
107 | + return false; |
|
108 | + } |
|
106 | 109 | |
107 | 110 | // load file translations |
108 | 111 | $addTranslation = require($path); |
109 | - if (!Any::isArray($addTranslation)) |
|
110 | - return false; |
|
112 | + if (!Any::isArray($addTranslation)) { |
|
113 | + return false; |
|
114 | + } |
|
111 | 115 | |
112 | 116 | // merge data |
113 | 117 | $this->cached = Arr::merge($this->cached, $addTranslation); |
@@ -142,11 +146,13 @@ discard block |
||
142 | 146 | $lang = App::$Request->getLanguage(); |
143 | 147 | } |
144 | 148 | // unserialize from string to array |
145 | - if (Any::isStr($input)) |
|
146 | - $input = Serialize::decode($input); |
|
149 | + if (Any::isStr($input)) { |
|
150 | + $input = Serialize::decode($input); |
|
151 | + } |
|
147 | 152 | |
148 | - if (Any::isArray($input) && array_key_exists($lang, $input)) |
|
149 | - return $input[$lang]; |
|
153 | + if (Any::isArray($input) && array_key_exists($lang, $input)) { |
|
154 | + return $input[$lang]; |
|
155 | + } |
|
150 | 156 | |
151 | 157 | return $default; |
152 | 158 | } |
@@ -3,7 +3,6 @@ |
||
3 | 3 | |
4 | 4 | use Ffcms\Core\App; |
5 | 5 | use Ffcms\Core\Helper\Type\Any; |
6 | -use Ffcms\Core\Helper\Type\Obj; |
|
7 | 6 | |
8 | 7 | /** |
9 | 8 | * Class EventManager. Control and run events. |
@@ -33,8 +33,9 @@ discard block |
||
33 | 33 | public function on($event, \Closure $callback): void |
34 | 34 | { |
35 | 35 | // check if event is a single string and parse it to array single item |
36 | - if (!Any::isArray($event)) |
|
37 | - $event = [$event]; |
|
36 | + if (!Any::isArray($event)) { |
|
37 | + $event = [$event]; |
|
38 | + } |
|
38 | 39 | |
39 | 40 | foreach ($event as $item) { |
40 | 41 | $this->events[$item][] = $callback; |
@@ -50,13 +51,15 @@ discard block |
||
50 | 51 | public function listen($event, \Closure $callback) |
51 | 52 | { |
52 | 53 | // check if $event is a single string and set it as array with one item |
53 | - if (!Any::isArray($event)) |
|
54 | - $event = [$event]; |
|
54 | + if (!Any::isArray($event)) { |
|
55 | + $event = [$event]; |
|
56 | + } |
|
55 | 57 | |
56 | 58 | // each every one event in array |
57 | 59 | foreach ($event as $item) { |
58 | - if (Any::isArray($this->runned) && array_key_exists($item, $this->runned)) |
|
59 | - return call_user_func_array($callback, $this->runned[$item]); |
|
60 | + if (Any::isArray($this->runned) && array_key_exists($item, $this->runned)) { |
|
61 | + return call_user_func_array($callback, $this->runned[$item]); |
|
62 | + } |
|
60 | 63 | } |
61 | 64 | |
62 | 65 | return false; |
@@ -71,8 +74,9 @@ discard block |
||
71 | 74 | // dynamicly parse input params |
72 | 75 | $args = func_get_args(); |
73 | 76 | |
74 | - if (count($args) < 1) |
|
75 | - return false; |
|
77 | + if (count($args) < 1) { |
|
78 | + return false; |
|
79 | + } |
|
76 | 80 | |
77 | 81 | // get event name |
78 | 82 | $eventName = array_shift($args); |
@@ -8,7 +8,6 @@ |
||
8 | 8 | use Ffcms\Core\Helper\FileSystem\Normalize; |
9 | 9 | use Ffcms\Core\Helper\Type\Any; |
10 | 10 | use Ffcms\Core\Helper\Type\Arr; |
11 | -use Ffcms\Core\Helper\Type\Obj; |
|
12 | 11 | use Ffcms\Core\Helper\Type\Str; |
13 | 12 | |
14 | 13 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | continue; |
71 | 71 | } |
72 | 72 | // check initialize conditions (equals to $exist) |
73 | - if (File::exist($this->dir . '/' . $migration)) { |
|
73 | + if (File::exist($this->dir.'/'.$migration)) { |
|
74 | 74 | if (Arr::in($fullName, $dbmigrations) === $exist) { |
75 | 75 | $found[] = $migration; |
76 | 76 | } |
@@ -100,16 +100,16 @@ discard block |
||
100 | 100 | } |
101 | 101 | |
102 | 102 | // check if migration file is exists |
103 | - if (!File::exist($this->dir . '/' . $file)) |
|
103 | + if (!File::exist($this->dir.'/'.$file)) |
|
104 | 104 | return false; |
105 | 105 | |
106 | 106 | // check if migration file located in extend directory and copy to default |
107 | 107 | if (Normalize::diskFullPath($this->dir) !== Normalize::diskFullPath(static::DEFAULT_DIR)) { |
108 | - File::copy($this->dir . DIRECTORY_SEPARATOR . $file, static::DEFAULT_DIR . DIRECTORY_SEPARATOR . $file); |
|
108 | + File::copy($this->dir.DIRECTORY_SEPARATOR.$file, static::DEFAULT_DIR.DIRECTORY_SEPARATOR.$file); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | // include migration and get class name |
112 | - File::inc($this->dir . '/' . $file, false, false); |
|
112 | + File::inc($this->dir.'/'.$file, false, false); |
|
113 | 113 | $fullName = Str::cleanExtension($file); |
114 | 114 | $class = Str::firstIn($fullName, '-'); |
115 | 115 | |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | } |
145 | 145 | |
146 | 146 | // check if exists |
147 | - if (!File::exist($this->dir . '/' . $file)) |
|
147 | + if (!File::exist($this->dir.'/'.$file)) |
|
148 | 148 | return false; |
149 | 149 | |
150 | - File::inc($this->dir . '/' . $file, false, false); |
|
150 | + File::inc($this->dir.'/'.$file, false, false); |
|
151 | 151 | $fullName = Str::cleanExtension($file); |
152 | 152 | $class = Str::firstIn($fullName, '-'); |
153 | 153 |
@@ -30,14 +30,16 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function __construct(?string $dir = null, ?string $connectionName = null) |
32 | 32 | { |
33 | - if ($dir === null) |
|
34 | - $dir = static::DEFAULT_DIR; |
|
33 | + if ($dir === null) { |
|
34 | + $dir = static::DEFAULT_DIR; |
|
35 | + } |
|
35 | 36 | |
36 | 37 | $this->dir = rtrim($dir, '/'); |
37 | 38 | $this->connection = $connectionName; |
38 | 39 | |
39 | - if ($this->dir !== static::DEFAULT_DIR) |
|
40 | - $this->customDir = true; |
|
40 | + if ($this->dir !== static::DEFAULT_DIR) { |
|
41 | + $this->customDir = true; |
|
42 | + } |
|
41 | 43 | } |
42 | 44 | |
43 | 45 | /** |
@@ -50,16 +52,18 @@ discard block |
||
50 | 52 | { |
51 | 53 | // initialize db migration record |
52 | 54 | $records = new Migration(); |
53 | - if ($this->connection !== null) |
|
54 | - $records->setConnection($this->connection); |
|
55 | + if ($this->connection !== null) { |
|
56 | + $records->setConnection($this->connection); |
|
57 | + } |
|
55 | 58 | |
56 | 59 | // get installed migrations |
57 | 60 | $dbmigrations = Arr::pluck('migration', $records->get()->toArray()); |
58 | 61 | |
59 | 62 | // list migrations |
60 | 63 | $migrations = File::listFiles($this->dir, ['.php'], true); |
61 | - if (!Any::isArray($migrations) || count($migrations) < 1) |
|
62 | - return false; |
|
64 | + if (!Any::isArray($migrations) || count($migrations) < 1) { |
|
65 | + return false; |
|
66 | + } |
|
63 | 67 | |
64 | 68 | $found = false; |
65 | 69 | foreach ($migrations as $migration) { |
@@ -100,8 +104,9 @@ discard block |
||
100 | 104 | } |
101 | 105 | |
102 | 106 | // check if migration file is exists |
103 | - if (!File::exist($this->dir . '/' . $file)) |
|
104 | - return false; |
|
107 | + if (!File::exist($this->dir . '/' . $file)) { |
|
108 | + return false; |
|
109 | + } |
|
105 | 110 | |
106 | 111 | // check if migration file located in extend directory and copy to default |
107 | 112 | if (Normalize::diskFullPath($this->dir) !== Normalize::diskFullPath(static::DEFAULT_DIR)) { |
@@ -114,8 +119,9 @@ discard block |
||
114 | 119 | $class = Str::firstIn($fullName, '-'); |
115 | 120 | |
116 | 121 | // check if class is instance of migration interface |
117 | - if (!class_exists($class) || !is_a($class, 'Ffcms\Core\Migrations\MigrationInterface', true)) |
|
118 | - return false; |
|
122 | + if (!class_exists($class) || !is_a($class, 'Ffcms\Core\Migrations\MigrationInterface', true)) { |
|
123 | + return false; |
|
124 | + } |
|
119 | 125 | |
120 | 126 | // implement migration |
121 | 127 | $init = new $class($fullName, $this->connection); |
@@ -144,8 +150,9 @@ discard block |
||
144 | 150 | } |
145 | 151 | |
146 | 152 | // check if exists |
147 | - if (!File::exist($this->dir . '/' . $file)) |
|
148 | - return false; |
|
153 | + if (!File::exist($this->dir . '/' . $file)) { |
|
154 | + return false; |
|
155 | + } |
|
149 | 156 | |
150 | 157 | File::inc($this->dir . '/' . $file, false, false); |
151 | 158 | $fullName = Str::cleanExtension($file); |