Completed
Pull Request — master (#430)
by Anton
04:25
created

NotEmptyRule::validate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Bluz Framework Component
4
 *
5
 * @copyright Bluz PHP Team
6
 * @link      https://github.com/bluzphp/framework
7
 */
8
9
declare(strict_types=1);
10
11
namespace Bluz\Validator\Rule;
12
13
/**
14
 * Check for not empty
15
 *
16
 * @package Bluz\Validator\Rule
17
 */
18
class NotEmptyRule extends AbstractRule
19
{
20
    /**
21
     * @var string error template
22
     */
23
    protected $description = 'must not be empty';
24
25
    /**
26
     * Check input data
27
     *
28
     * @param  mixed $input
29
     *
30
     * @return bool
31
     */
32 13
    public function validate($input): bool
33
    {
34 13
        if (is_string($input)) {
35 6
            $input = trim($input);
36
        }
37
38 13
        return !empty($input);
39
    }
40
}
41