NotEmptyRule::validate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

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