OptionsRequiredTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 22
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A checkRequired() 0 8 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