PropertyReadOnlyException::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
cc 2
eloc 5
nc 2
nop 3
crap 2
1
<?php
2
3
namespace Marek\Toggable\API\Exception;
4
5
use Exception;
6
7
/**
8
 * Class PropertyReadOnlyException
9
 * @package Marek\Toggable\Exception
10
 */
11
class PropertyReadOnlyException extends Exception
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
{
13
    /**
14
     * Generates: Property '{$propertyName}' is readonly[ on class '{$className}'].
15
     *
16
     * @param string $propertyName
17
     * @param string|null $className Optionally to specify class in abstract/parent classes
18
     * @param \Exception|null $previous
19
     */
20 2
    public function __construct($propertyName, $className = null, Exception $previous = null)
21
    {
22 2
        if ($className === null) {
23 1
            parent::__construct("Property '{$propertyName}' is readonly", 0, $previous);
24 1
        } else {
25 1
            parent::__construct("Property '{$propertyName}' is readonly on class '{$className}'", 0, $previous);
26
        }
27 2
    }
28
}
29