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

CheckPlatformData::check()   B

Complexity

Conditions 10
Paths 2

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 10

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 12
cts 12
cp 1
rs 7.2765
c 0
b 0
f 0
cc 10
eloc 11
nc 2
nop 2
crap 10

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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 CheckPlatformData
22
{
23
    /**
24
     * checks if platform 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('Platform', $properties)
36 7
            || array_key_exists('Platform_Description', $properties)
37 7
            || array_key_exists('Platform_Maker', $properties)
38 7
            || array_key_exists('Platform_Bits', $properties)
39 7
            || array_key_exists('Platform_Version', $properties)
40 7
            || array_key_exists('Win16', $properties)
41 7
            || array_key_exists('Win32', $properties)
42 7
            || array_key_exists('Win64', $properties)
43 7
            || array_key_exists('Browser_Bits', $properties)
44
        ) {
45 1
            throw new \LogicException($message);
46
        }
47 7
    }
48
}
49