InvalidArgumentException::fromValidTypes()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 5
nc 1
nop 2
1
<?php
2
declare(strict_types=1);
3
4
namespace AcMailer\Exception;
5
6
/**
7
 * Exception produced when an argument provided for an AcMailer method is not valid
8
 * @author Alejandro Celaya Alastrué
9
 * @link http://www.alejandrocelaya.com
10
 */
11
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
12
{
13
    public static function fromValidTypes(array $types, $value): self
14
    {
15
        return new self(\sprintf(
16
            'Provided email is not valid. Expected one of ["%s"], but "%s" was provided',
17
            \implode('", "', $types),
18
            \is_object($value) ? \get_class($value) : \gettype($value)
19
        ));
20
    }
21
}
22