NoInterfaceException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A generateMessage() 0 7 1
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