IncompatibleDataException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1
1
<?php
2
namespace Consolidation\OutputFormatters\Exception;
3
4
use Consolidation\OutputFormatters\Formatters\FormatterInterface;
5
6
/**
7
 * Represents an incompatibility between the output data and selected formatter.
8
 */
9
class IncompatibleDataException extends AbstractDataFormatException
10
{
11 3
    public function __construct(FormatterInterface $formatter, $data, $allowedTypes)
12
    {
13 3
        $formatterDescription = get_class($formatter);
14 3
        $dataDescription = static::describeDataType($data);
15 3
        $allowedTypesDescription = static::describeAllowedTypes($allowedTypes);
16 3
        $message = "Data provided to $formatterDescription must be $allowedTypesDescription. Instead, $dataDescription was provided.";
17 3
        parent::__construct($message, 1);
18 3
    }
19
}
20