PropertyAccessException   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 43
ccs 7
cts 7
cp 1
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 1
1
<?php
2
/**
3
 * This file is part of the Composite Utils package.
4
 *
5
 * (c) Emily Shepherd <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the
8
 * LICENSE.md file that was distributed with this source code.
9
 *
10
 * @package spaark/composite-utils
11
 * @author Emily Shepherd <[email protected]>
12
 * @license MIT
13
 */
14
15
namespace Spaark\CompositeUtils\Exception;
16
17
use LogicException;
18
use Throwable;
19
20
/**
21
 * Thrown when a property cannot be accessed for any reason
22
 */
23
class PropertyAccessException extends LogicException
24
{
25
    /**
26
     * The type of access for the error message
27
     *
28
     * Overridden by child classes to provide detailed error feedback.
29
     * Example values might be 'read' or 'write'.
30
     */
31
    const ACCESS_TYPE = 'access';
32
33
    /**
34
     * The type of error for the error message
35
     *
36
     * Overridden by child classes to provide detailed error feedback.
37
     * Example values might be 'Permission denied' or 'Property does not
38
     * exist'
39
     */
40
    const ERROR_REASON = 'Generic Failure';
41
42
    /**
43
     * Creates the exception, populating its error message from class
44
     * and property names
45
     *
46
     * @param string $class The classname accessed
47
     * @param string $property The property accessed
48
     * @param Throwable $previous The exception which caused this
49
     */
50 8
    public function __construct
51
    (
52
        string $class,
53
        string $property,
54
        Throwable $previous = null
55
    )
56
    {
57 8
        parent::__construct
58
        (
59 8
              'Cannot ' . static::ACCESS_TYPE . ' property: '
60 8
            . $class . '::$' . $property . '. ' . static::ERROR_REASON,
61 8
            0,
62 8
            $previous
63
        );
64 8
    }
65
}
66