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

FormatterException::needsQuality()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2.0932

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
ccs 5
cts 7
cp 0.7143
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
crap 2.0932
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