Completed
Pull Request — master (#423)
by Marco
24:53
created

unsupportedLocalizedReflectionProperty()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 3
cts 3
cp 1
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManager\Exception;
6
7
use LogicException;
8
use ProxyManager\ProxyGenerator\Util\Properties;
9
use ReflectionClass;
10
use ReflectionProperty;
11
use function array_map;
12
use function implode;
13
use function sprintf;
14
15
/**
16
 * Exception for invalid proxied classes
17 1
 *
18
 */
19 1
class UnsupportedProxiedClassException extends LogicException implements ExceptionInterface
20 1
{
21 1
    public static function unsupportedLocalizedReflectionProperty(ReflectionProperty $property) : self
22 1
    {
23 1
        return new self(
24
            sprintf(
25
                'Provided reflection property "%s" of class "%s" is private and cannot be localized in PHP 5.3',
26
                $property->getName(),
27
                $property->getDeclaringClass()->getName()
28
            )
29
        );
30
    }
31
32
    public static function nonReferenceableLocalizedReflectionProperties(
33
        ReflectionClass $class,
34
        Properties $properties
35
    ) : self {
36
        return new self(sprintf(
37
            'Cannot create references for following properties of class %s: %s',
38
            $class->getName(),
39
            implode(', ', array_map(function (ReflectionProperty $property) : string {
40
                return $property->getName();
41
            }, $properties->getInstanceProperties()))
42
        ));
43
    }
44
}
45