Completed
Push — master ( 3ebd9f...ed37c4 )
by Woody
02:43
created

FormatterException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 73.32%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 37
ccs 11
cts 15
cp 0.7332
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A invalidClass() 0 12 2
A needsQuality() 0 11 2
1
<?php
2
3
namespace Equip\Exception;
4
5
use Equip\Formatter\FormatterInterface;
6
use InvalidArgumentException;
7
8
class FormatterException extends InvalidArgumentException
9
{
10
    /**
11
     * @param string|object $spec
12
     *
13
     * @return static
14
     */
15 1
    public static function invalidClass($spec)
16
    {
17 1
        if (is_object($spec)) {
18
            $spec = get_class($spec);
19
        }
20
21 1
        return new static(sprintf(
22 1
            'Formatter class `%s` must implement `%s`',
23 1
            $spec,
24
            FormatterInterface::class
25 1
        ));
26
    }
27
28
    /**
29
      * @param string|object $formatter
30
      *
31
      * @return static
32
      */
33 1
     public static function needsQuality($formatter)
34
     {
35 1
         if (is_object($formatter)) {
36
             $formatter = get_class($formatter);
37
         }
38
39 1
         return new static(sprintf(
40 1
             'No quality have been set for the `%s` formatter',
41
             $formatter
42 1
         ));
43
     }
44
}
45