NotNull::validate()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 4
nc 4
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Linio\Component\Input\Constraint;
6
7
class NotNull extends Constraint
8
{
9
    public function __construct(string $errorMessage = null)
10
    {
11
        $this->setErrorMessage($errorMessage ?? 'Unexpected empty content');
12
    }
13
14
    public function validate($content): bool
15
    {
16
        if ($content && is_string($content)) {
17
            $content = trim($content);
18
        }
19
20
        return $content !== null && $content !== '';
21
    }
22
}
23