OptionsRequiredTrait::checkRequired()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
crap 2
1
<?php
2
3
namespace Equip\Command;
4
5
/**
6
 * Provides required parameter functionality for options.
7
 */
8
trait OptionsRequiredTrait
9
{
10
    /**
11
     * Check that the given options contain all required keys.
12
     *
13
     * @param array $options
14
     * @param array $keys
15
     *
16
     * @return void
17
     *
18
     * @throws CommandException
19
     *  If any required options are missing.
20
     */
21 2
    private function checkRequired(array $options, array $keys)
22
    {
23 2
        $missing = array_keys(array_diff_key(array_flip($keys), $options));
24
25 2
        if (!empty($missing)) {
26 1
            throw CommandException::missingOptions($missing);
27
        }
28 1
    }
29
}
30