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

UnsupportedProxiedClassException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 26
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A unsupportedLocalizedReflectionProperty() 0 10 1
A nonReferenceableLocalizedReflectionProperties() 0 12 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
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