Completed
Push — master ( 2f25cf...59cc7f )
by Marco
43:54 queued 18:55
created

nonReferenceableLocalizedReflectionProperties()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 0
cp 0
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
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
class UnsupportedProxiedClassException extends LogicException implements ExceptionInterface
19 1
{
20 1
    public static function unsupportedLocalizedReflectionProperty(ReflectionProperty $property) : self
21 1
    {
22 1
        return new self(
23 1
            sprintf(
24
                'Provided reflection property "%s" of class "%s" is private and cannot be localized in PHP 5.3',
25
                $property->getName(),
26
                $property->getDeclaringClass()->getName()
27
            )
28
        );
29
    }
30
31
    public static function nonReferenceableLocalizedReflectionProperties(
32
        ReflectionClass $class,
33
        Properties $properties
34
    ) : self {
35
        return new self(sprintf(
36
            'Cannot create references for following properties of class %s: %s',
37
            $class->getName(),
38
            implode(', ', array_map(static function (ReflectionProperty $property) : string {
39
                return $property->getName();
40
            }, $properties->getInstanceProperties()))
41
        ));
42
    }
43
}
44