Completed
Push — master ( 7a5cb9...59abba )
by Hannes
02:54
created

ArgumentsCheckTrait::checkArguments()   B

Complexity

Conditions 6
Paths 4

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 6

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 14
ccs 8
cts 8
cp 1
rs 8.8571
cc 6
eloc 7
nc 4
nop 3
crap 6
1
<?php
2
3
/*
4
 * This file is part of the Runalyze DEM Reader.
5
 *
6
 * (c) RUNALYZE <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Runalyze\DEM\Interpolation;
13
14
use Runalyze\DEM\Exception\InvalidArgumentException;
15
16
trait ArgumentsCheckTrait
17
{
18
    /**
19
     * @param  float                    $x
20
     * @param  float                    $y
21
     * @param  array                    $elevationOnBoundingBox elevation data on [p0, p1, p2, p3]
22
     * @throws InvalidArgumentException
23
     */
24 19
    protected function checkArguments($x, $y, array $elevationOnBoundingBox)
25
    {
26 19
        if (4 !== count($elevationOnBoundingBox)) {
27 4
            throw new InvalidArgumentException('Array with elevation on bounding box must have four values.');
28
        }
29
30 15
        if ($x < 0.0 || 1.0 < $x) {
31 2
            throw new InvalidArgumentException('$x must be within [0.0, 1.0]');
32
        }
33
34 13
        if ($y < 0.0 || 1.0 < $y) {
35 2
            throw new InvalidArgumentException('$y must be within [0.0, 1.0]');
36
        }
37 11
    }
38
}
39