Completed
Push — master ( 8f1053...c250e4 )
by Antonio
13:19
created

RecipientsHelper::sanitize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

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