Completed
Branch feature/SRTM1ArcSecond (5f684d)
by Hannes
04:35
created

ArgumentsCheckTrait::checkArguments()   B

Complexity

Conditions 6
Paths 4

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 42

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 0
cts 12
cp 0
rs 8.8571
c 0
b 0
f 0
cc 6
eloc 7
nc 4
nop 3
crap 42
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
    protected function checkArguments($x, $y, array $elevationOnBoundingBox)
25
    {
26
        if (4 !== count($elevationOnBoundingBox)) {
27
            throw new InvalidArgumentException('Array with elevation on bounding box must have four values.');
28
        }
29
30
        if ($x < 0.0 || 1.0 < $x) {
31
            throw new InvalidArgumentException('$x must be within [0.0, 1.0]');
32
        }
33
34
        if ($y < 0.0 || 1.0 < $y) {
35
            throw new InvalidArgumentException('$y must be within [0.0, 1.0]');
36
        }
37
    }
38
}
39