Completed
Push — master ( dfa316...88ba24 )
by Gareth
05:20
created

ensureIsArray.php ➔ ensureIsMailbox()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 1
dl 0
loc 10
ccs 6
cts 6
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace garethp\ews\Utilities;
4
5
use garethp\ews\API\Type;
6
7
/**
8
 * @param $input
9
 * @param $checkAssoc
10
 * @return array
11
 */
12
function ensureIsArray($input, $checkAssoc = false)
13
{
14 22
    if (!is_array($input)) {
15 19
        return [$input];
16
    }
17
18 19
    if ($checkAssoc && Type::arrayIsAssoc($input)) {
19 4
        return [$input];
20
    }
21
22 19
    return $input;
23
}
24
25
function ensureIsMailbox($input)
26
{
27 2
    if (is_string($input)) {
28 2
        $address = new Type\Mailbox();
29 2
        $address->setEmailAddress($input);
30 2
        $input = $address;
31 2
    }
32
33 2
    return $input;
34
}
35