Skip to content

Commit b7e1d5a

Browse files
committed
Merge branch 'new' into development
# Conflicts: # src/Validation.php # src/Validator.php
2 parents f7d45d7 + 66d372e commit b7e1d5a

File tree

7 files changed

+31
-29
lines changed

7 files changed

+31
-29
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ indent_style = space
88
insert_final_newline = true
99
trim_trailing_whitespace = true
1010

11-
[*.{md, rst}]
11+
[*.{md,rst}]
1212
trim_trailing_whitespace = false
1313

1414
[*.yml]

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
},
4141
"require-dev": {
4242
"ext-xdebug": "*",
43-
"aplus/coding-standard": "^1.14",
43+
"aplus/coding-standard": "^2.0",
4444
"ergebnis/composer-normalize": "^2.25",
4545
"jetbrains/phpstorm-attributes": "^1.0",
4646
"phpmd/phpmd": "^2.13",

guide/index.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ To validate only one field is possible to use only the Validator:
133133
Working with Arrays
134134
-------------------
135135

136-
Validator uses the `ArraySimple <https://gitlab.com/aplus-framework/libraries/helpers>`_
136+
Validator uses the `ArraySimple <https://github.com/aplus-framework/helpers>`_
137137
class to extract fields and get the correct data value.
138138

139139
.. code-block:: php
@@ -849,5 +849,5 @@ The more you use it, the more you will learn.
849849
.. note::
850850
Did you find something wrong?
851851
Be sure to let us know about it with an
852-
`issue <https://gitlab.com/aplus-framework/libraries/validation/issues>`_.
852+
`issue <https://github.com/aplus-framework/validation/issues>`_.
853853
Thank you!

src/Debug/ValidationCollector.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function setErrorInDebugData(string $field, string $error, int $index = -
6363

6464
public function getContents() : string
6565
{
66-
if ( ! isset($this->validation)) {
66+
if (!isset($this->validation)) {
6767
return '<p>A Validation instance has not been set in this collector.</p>';
6868
}
6969
\ob_start(); ?>
@@ -79,7 +79,7 @@ public function getContents() : string
7979

8080
protected function renderValidations() : string
8181
{
82-
if ( ! $this->hasData()) {
82+
if (!$this->hasData()) {
8383
return '<p>Validation did not run.</p>';
8484
}
8585
$count = \count($this->getData());
@@ -130,7 +130,7 @@ protected function renderValidations() : string
130130

131131
protected function renderRuleset() : string
132132
{
133-
if ( ! $this->validation->getRules()) {
133+
if (!$this->validation->getRules()) {
134134
return '<p>No rules have been set.</p>';
135135
}
136136
\ob_start(); ?>

src/FilesValidator.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static function uploaded(string $field, array $data = []) : bool
7373
public static function maxSize(string $field, array $data, int $kilobytes) : bool
7474
{
7575
$uploaded = static::uploaded($field);
76-
if ( ! $uploaded) {
76+
if (!$uploaded) {
7777
return false;
7878
}
7979
$file = static::getFile($field);
@@ -92,7 +92,7 @@ public static function maxSize(string $field, array $data, int $kilobytes) : boo
9292
public static function mimes(string $field, array $data, string ...$allowedTypes) : bool
9393
{
9494
$uploaded = static::uploaded($field);
95-
if ( ! $uploaded) {
95+
if (!$uploaded) {
9696
return false;
9797
}
9898
$file = static::getFile($field);
@@ -115,7 +115,7 @@ public static function mimes(string $field, array $data, string ...$allowedTypes
115115
public static function ext(string $field, array $data, string ...$allowedExtensions) : bool
116116
{
117117
$uploaded = static::uploaded($field);
118-
if ( ! $uploaded) {
118+
if (!$uploaded) {
119119
return false;
120120
}
121121
$file = static::getFile($field);
@@ -138,7 +138,7 @@ public static function ext(string $field, array $data, string ...$allowedExtensi
138138
public static function image(string $field, array $data = []) : bool
139139
{
140140
$uploaded = static::uploaded($field);
141-
if ( ! $uploaded) {
141+
if (!$uploaded) {
142142
return false;
143143
}
144144
$file = static::getFile($field);
@@ -159,12 +159,12 @@ public static function image(string $field, array $data = []) : bool
159159
public static function maxDim(string $field, array $data, int $width, int $height) : bool
160160
{
161161
$isImage = static::image($field);
162-
if ( ! $isImage) {
162+
if (!$isImage) {
163163
return false;
164164
}
165165
$file = static::getFile($field);
166166
$sizes = \getimagesize($file['tmp_name']);
167-
return ! ($sizes === false || $sizes[0] > $width || $sizes[1] > $height);
167+
return !($sizes === false || $sizes[0] > $width || $sizes[1] > $height);
168168
}
169169

170170
/**
@@ -180,12 +180,12 @@ public static function maxDim(string $field, array $data, int $width, int $heigh
180180
public static function minDim(string $field, array $data, int $width, int $height) : bool
181181
{
182182
$isImage = static::image($field);
183-
if ( ! $isImage) {
183+
if (!$isImage) {
184184
return false;
185185
}
186186
$file = static::getFile($field);
187187
$sizes = \getimagesize($file['tmp_name']);
188-
return ! ($sizes === false || $sizes[0] < $width || $sizes[1] < $height);
188+
return !($sizes === false || $sizes[0] < $width || $sizes[1] < $height);
189189
}
190190

191191
/**
@@ -201,11 +201,11 @@ public static function minDim(string $field, array $data, int $width, int $heigh
201201
public static function dim(string $field, array $data, int $width, int $height) : bool
202202
{
203203
$isImage = static::image($field);
204-
if ( ! $isImage) {
204+
if (!$isImage) {
205205
return false;
206206
}
207207
$file = static::getFile($field);
208208
$sizes = \getimagesize($file['tmp_name']);
209-
return ! ($sizes === false || $sizes[0] !== $width || $sizes[1] !== $height);
209+
return !($sizes === false || $sizes[0] !== $width || $sizes[1] !== $height);
210210
}
211211
}

src/Validation.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function setLanguage(Language $language = null) : static
9696

9797
public function getLanguage() : Language
9898
{
99-
if ( ! isset($this->language)) {
99+
if (!isset($this->language)) {
100100
$this->setLanguage();
101101
}
102102
return $this->language;
@@ -471,7 +471,7 @@ protected function validateField(string $field, array $rules, array $data) : boo
471471
// Field is optional. If the field is undefined, validation passes.
472472
if ($rule['rule'] === 'optional') {
473473
$removeKeys[] = $key;
474-
if ( ! $fieldExists) {
474+
if (!$fieldExists) {
475475
return true;
476476
}
477477
}
@@ -563,7 +563,7 @@ protected function run(array $fieldRules, array $data) : bool
563563
$result = true;
564564
foreach ($fieldRules as $field => $rules) {
565565
$status = $this->validateField($field, $rules, $data);
566-
if ( ! $status) {
566+
if (!$status) {
567567
$result = false;
568568
}
569569
}

src/Validator.php

+11-9
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ public static function json(string $field, array $data) : bool
204204
public static function regex(
205205
string $field,
206206
array $data,
207-
#[Language('RegExp')] string $pattern
207+
#[Language('RegExp')]
208+
string $pattern
208209
) : bool {
209210
$data = static::getData($field, $data);
210211
return $data !== null && \preg_match($pattern, $data) === 1;
@@ -222,9 +223,10 @@ public static function regex(
222223
public static function notRegex(
223224
string $field,
224225
array $data,
225-
#[Language('RegExp')] string $pattern
226+
#[Language('RegExp')]
227+
string $pattern
226228
) : bool {
227-
return ! static::regex($field, $data, $pattern);
229+
return !static::regex($field, $data, $pattern);
228230
}
229231

230232
/**
@@ -239,11 +241,11 @@ public static function notRegex(
239241
public static function equals(string $field, array $data, string $equalsField) : bool
240242
{
241243
$field = ArraySimple::value($field, $data);
242-
if ( ! \is_scalar($field)) {
244+
if (!\is_scalar($field)) {
243245
return false;
244246
}
245247
$equalsField = ArraySimple::value($equalsField, $data);
246-
if ( ! \is_scalar($equalsField)) {
248+
if (!\is_scalar($equalsField)) {
247249
return false;
248250
}
249251
return (string) $field === (string) $equalsField;
@@ -260,7 +262,7 @@ public static function equals(string $field, array $data, string $equalsField) :
260262
*/
261263
public static function notEquals(string $field, array $data, string $diffField) : bool
262264
{
263-
return ! static::equals($field, $data, $diffField);
265+
return !static::equals($field, $data, $diffField);
264266
}
265267

266268
/**
@@ -299,7 +301,7 @@ public static function notBetween(
299301
int | string $min,
300302
int | string $max
301303
) : bool {
302-
return ! static::between($field, $data, $min, $max);
304+
return !static::between($field, $data, $min, $max);
303305
}
304306

305307
/**
@@ -330,7 +332,7 @@ public static function in(string $field, array $data, string $in, string ...$oth
330332
*/
331333
public static function notIn(string $field, array $data, string $notIn, string ...$others) : bool
332334
{
333-
return ! static::in($field, $data, $notIn, ...$others);
335+
return !static::in($field, $data, $notIn, ...$others);
334336
}
335337

336338
/**
@@ -376,7 +378,7 @@ public static function url(string $field, array $data) : bool
376378
return false;
377379
}
378380
if (\preg_match('/^(?:([^:]*)\:)?\/\/(.+)$/', $data, $matches)) {
379-
if ( ! \in_array($matches[1], ['http', 'https'], true)) {
381+
if (!\in_array($matches[1], ['http', 'https'], true)) {
380382
return false;
381383
}
382384
$data = $matches[2];

0 commit comments

Comments
 (0)