NoInterfaceException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 3
1
<?php
2
/**
3
 * This file is part of the phpspec-behavior package.
4
 * (c) 2017 Timo Michna <timomichna/yahoo.de>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Tidal\PhpSpec\BehaviorExtension\Exception;
11
12
use RuntimeException;
13
use Throwable;
14
15
class NoInterfaceException extends RuntimeException
16
{
17
    private const MESSAGE_PATTERN = 'Argument is not an interface. Given : %s';
18
19
    public function __construct(string $interfaceName, int $code = 0, Throwable $previous = null)
20
    {
21
        parent::__construct(
22
            self::generateMessage($interfaceName),
23
            $code,
24
            $previous
25
        );
26
    }
27
28
    /**
29
     * @param string $interfaceName
30
     * @return string
31
     */
32
    private static function generateMessage(string $interfaceName)
33
    {
34
        return (sprintf(
35
            self::MESSAGE_PATTERN,
36
            $interfaceName
37
        ));
38
    }
39
}
40