NoiseIsAcceptable   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 12
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A evaluate() 0 10 2
1
<?php
2
3
namespace XSolve\FaceValidatorBundle\Validator\Specification;
4
5
use XSolve\FaceValidatorBundle\Result\FaceDetectionResult;
6
use XSolve\FaceValidatorBundle\Result\NoiseLevel;
7
use XSolve\FaceValidatorBundle\Validator\Constraints\Face;
8
9
class NoiseIsAcceptable implements FaceValidationSpecification
10
{
11
    public function evaluate(FaceDetectionResult $result, Face $constraint): Evaluation
12
    {
13
        $acceptableLevel = new NoiseLevel($constraint->maxNoiseLevel);
14
        $actualLevel = $result->getNoise()->getLevel();
15
16
        if ($actualLevel->isLowerOrEqual($acceptableLevel)) {
17
            return new Evaluation(true);
18
        }
19
20
        return new Evaluation(false, $constraint->noiseMessage);
21
    }
22
}
23