RecipientsHelper::sanitize()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 2
rs 10
1
<?php
2
3
namespace Da\Mailer\Helper;
4
5
class RecipientsHelper
6
{
7
    /**
8
     * Trims recipients. If string, will split into array based on commas or semicolons delimiters.
9
     *
10
     * @param string|array $recipients
11
     *
12
     * @return array
13 4
     */
14
    public static function sanitize($recipients)
15 4
    {
16 4
        return is_string($recipients)
17 4
            ? array_filter(array_map('trim', preg_split('/(,|;)/', $recipients)))
18
            : array_filter(array_map('trim', (array) $recipients));
19
    }
20
}
21