ValidationError::getAttributeName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the tmilos/scim-schema package.
5
 *
6
 * (c) Milos Tomic <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Tmilos\ScimSchema\Validator;
13
14
class ValidationError
15
{
16
    /** @var string */
17
    private $attributeName;
18
19
    /** @var string */
20
    private $parentAttribute;
21
22
    /** @var string */
23
    private $schemaId;
24
25
    /** @var string */
26
    private $message;
27
28
    /**
29
     * @param string $attributeName
30
     * @param string $parentAttribute
31
     * @param string $schemaId
32
     * @param string $message
33
     */
34
    public function __construct($attributeName, $parentAttribute, $schemaId, $message)
35
    {
36
        $this->attributeName = $attributeName;
37
        $this->parentAttribute = $parentAttribute;
38
        $this->schemaId = $schemaId;
39
        $this->message = $message;
40
    }
41
42
    /**
43
     * @return string
44
     */
45
    public function getAttributeName()
46
    {
47
        return $this->attributeName;
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function getParentAttribute()
54
    {
55
        return $this->parentAttribute;
56
    }
57
58
    /**
59
     * @return string
60
     */
61
    public function getSchemaId()
62
    {
63
        return $this->schemaId;
64
    }
65
66
    /**
67
     * @return string
68
     */
69
    public function getMessage()
70
    {
71
        return $this->message;
72
    }
73
74
    public function __toString()
75
    {
76
        return sprintf(
77
            '[%s%s] %s [%s]',
78
            $this->parentAttribute ? $this->parentAttribute.'.' : '',
79
            $this->attributeName,
80
            $this->message,
81
            $this->schemaId
82
        );
83
    }
84
}
85