FaceIsOfAcceptableAngle::evaluate()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
c 0
b 0
f 0
rs 9.4285
cc 3
eloc 5
nc 3
nop 2
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