Completed
Pull Request — master (#1596)
by Thomas
03:41
created

CheckDeviceData::check()   B

Complexity

Conditions 9
Paths 2

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 9

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 11
cts 11
cp 1
rs 7.756
c 0
b 0
f 0
cc 9
eloc 10
nc 2
nop 2
crap 9
1
<?php
2
/**
3
 * This file is part of the browscap package.
4
 *
5
 * Copyright (c) 1998-2017, Browser Capabilities Project
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
declare(strict_types = 1);
12
namespace Browscap\Data\Helper;
13
14
/**
15
 * Class DataCollection
16
 *
17
 * @category   Browscap
18
 *
19
 * @author     James Titcumb <[email protected]>
20
 */
21
class CheckDeviceData
22
{
23
    /**
24
     * checks if device properties are set inside a properties array
25
     *
26
     * @param array  $properties
27
     * @param string $message
28
     *
29
     * @throws \LogicException
30
     *
31
     * @return void
32
     */
33 8
    public function check(array $properties, string $message) : void
34
    {
35 8
        if (array_key_exists('Device_Name', $properties)
36 7
            || array_key_exists('Device_Maker', $properties)
37 7
            || array_key_exists('Device_Type', $properties)
38 7
            || array_key_exists('Device_Pointing_Method', $properties)
39 7
            || array_key_exists('Device_Code_Name', $properties)
40 7
            || array_key_exists('Device_Brand_Name', $properties)
41 7
            || array_key_exists('isMobileDevice', $properties)
42 7
            || array_key_exists('isTablet', $properties)
43
        ) {
44 1
            throw new \LogicException($message);
45
        }
46 7
    }
47
}
48