FaceIsOfAcceptableAngle   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 13
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A evaluate() 0 11 3
1
<?php
2
3
namespace XSolve\FaceValidatorBundle\Validator\Specification;
4
5
use XSolve\FaceValidatorBundle\Result\FaceDetectionResult;
6
use XSolve\FaceValidatorBundle\Validator\Constraints\Face;
7
8
class FaceIsOfAcceptableAngle implements FaceValidationSpecification
9
{
10
    public function evaluate(FaceDetectionResult $result, Face $constraint): Evaluation
11
    {
12
        $rotation = $result->getRotation();
13
14
        foreach ([$rotation->getX(), $rotation->getY(), $rotation->getZ()] as $rotationValue) {
15
            if ($rotationValue > $constraint->maxFaceRotation) {
16
                return new Evaluation(false, $constraint->tooMuchRotatedMessage);
17
            }
18
        }
19
20
        return new Evaluation(true);
21
    }
22
}
23