Completed
Pull Request — master (#423)
by Marco
24:53
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
 */
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