Passed
Pull Request — master (#33)
by Vincent
06:12
created

UninitializedPropertyException::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 10
cc 1
nc 1
nop 3
crap 2
1
<?php
2
3
namespace Bdf\Prime\Entity\Hydrator\Exception;
4
5
use Bdf\Prime\Entity\Hydrator\MapperHydratorInterface;
6
use Error;
7
use RuntimeException;
8
9
/**
10
 * Exception raised when trying to access a not initialized typed property
11
 * To fix this error, you should set a value (i.e. call the setter), or define a default value on property declaration
12
 *
13
 * @see MapperHydratorInterface::extractOne()
14
 * @see MapperHydratorInterface::flatExtract()
15
 */
16
class UninitializedPropertyException extends RuntimeException implements HydratorException
17
{
18
    /**
19
     * @param class-string $className
0 ignored issues
show
introduced by
Expected "classstring" but found "class-string" for parameter type
Loading history...
Documentation Bug introduced by
The doc comment class-string at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string.
Loading history...
20
     * @param string $propertyName
21
     *
22
     * @param Error|null $previous
0 ignored issues
show
Coding Style introduced by
Parameter tags must be grouped together in a doc comment
Loading history...
23
     */
24
    public function __construct(string $className, string $propertyName, Error $previous = null)
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before function; 0 found
Loading history...
25
    {
26
        parent::__construct(
27
            'Trying to read the property '.$className.'::'.$propertyName.' which is not yet initialized. Maybe you have forgot to call the setter or define a default value on the property declaration ?',
28
            0, $previous
29
        );
30
    }
31
}
32