Passed
Push — master ( 3bffb6...f32028 )
by Aleksandr
31:58
created

NotBlankConstraint::validate()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
namespace Drobotik\Eav\Validation\Constraints;
4
5
use Drobotik\Eav\Interface\ConstraintInterface;
6
7
class NotBlankConstraint implements ConstraintInterface
8
{
9
    public function validate($value): ?string
10
    {
11
        if (!is_string($value) || trim($value) === '') {
12
            return "This value cannot be blank.";
13
        }
14
        return null;
15
    }
16
}