ValidateSchemaException   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 6
Bugs 0 Features 0
Metric Value
dl 0
loc 62
rs 10
c 6
b 0
f 0
wmc 1
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getItemFromVariableArray() 0 4 1
1
<?php namespace CMPayments\SchemaValidator\Exceptions;
2
3
use CMPayments\Exception\BaseException;
4
5
/**
6
 * Class ValidateSchemaException
7
 *
8
 * @package CMPayments\SchemaValidator\Exceptions
9
 * @Author  Boy Wijnmaalen <[email protected]>
10
 */
11
class ValidateSchemaException extends BaseException
12
{
13
    const ERROR_SCHEMA_IS_NOT_VALID_JSON                                    = 1;
14
    const ERROR_INPUT_IS_NOT_A_OBJECT                                       = 2;
15
    const ERROR_SCHEMA_CANNOT_BE_EMPTY_IN_PATH                              = 3;
16
    const ERROR_EMPTY_KEY_NOT_ALLOWED_IN_OBJECT                             = 4;
17
    const ERROR_SCHEMA_PROPERTY_NOT_DEFINED                                 = 5;
18
    const ERROR_SCHEMA_PROPERTY_VALUE_IS_NOT_VALID                          = 6;
19
    const ERROR_SCHEMA_PROPERTY_TYPE_NOT_VALID                              = 7;
20
    const ERROR_SCHEMA_MAX_PROPERTY_CANNOT_NOT_BE_ZERO                      = 8;
21
    const ERROR_SCHEMA_PROPERTY_MIN_NOT_BIGGER_THAN_MAX                     = 9;
22
    const ERROR_SCHEMA_PROPERTY_REQUIRED_MUST_BE_AN_ARRAY                   = 10;
23
    const ERROR_SCHEMA_REQUIRED_AND_PROPERTIES_MUST_MATCH                   = 11;
24
    const ERROR_INVALID_REFERENCE                                           = 12;
25
    const ERROR_NO_LOCAL_DEFINITIONS_HAVE_BEEN_DEFINED                      = 13;
26
    const ERROR_CHECK_IF_LOCAL_DEFINITIONS_EXISTS                           = 14;
27
    const ERROR_CURL_NOT_INSTALLED                                          = 15;
28
    const ERROR_REMOTE_REFERENCE_DOES_NOT_EXIST                             = 16;
29
    const ERROR_NO_DATA_WAS_FOUND_IN_REMOTE_SCHEMA                          = 17;
30
    const ERROR_NO_VALID_JSON_WAS_FOUND_IN_REMOTE_SCHEMA                    = 18;
31
    const ERROR_INPUT_IS_NOT_A_VALID_PREPOSITION                            = 19;
32
    const ERROR_SCHEMA_PROPERTY_TYPE_IS_ARRAY_BUT_VALUES_ARE_NOT_UNIQUE     = 20;
33
    const ERROR_SCHEMA_PROPERTY_TYPE_IS_ARRAY_BUT_VALUES_AR_NOT_ALL_STRINGS = 21;
34
35
    protected $messages = [
36
        self::ERROR_SCHEMA_IS_NOT_VALID_JSON                                    => 'Schema is not valid JSON',
37
        self::ERROR_INPUT_IS_NOT_A_OBJECT                                       => '\'%s\' is not an object but %s \'%s\'%s',
38
        self::ERROR_SCHEMA_CANNOT_BE_EMPTY_IN_PATH                              => 'The Schema input cannot be empty in %s',
39
        self::ERROR_EMPTY_KEY_NOT_ALLOWED_IN_OBJECT                             => 'It\'s not allowed for object \'%s\' to have an empty key',
40
        self::ERROR_SCHEMA_PROPERTY_NOT_DEFINED                                 => 'The mandatory Schema Property \'%s\' is not defined for \'%s\'',
41
        self::ERROR_SCHEMA_PROPERTY_VALUE_IS_NOT_VALID                          => 'The given value \'%s\' for property \'%s.%s\' is not valid. Please use %sthe following %s: \'%s\'',
42
        self::ERROR_SCHEMA_PROPERTY_TYPE_NOT_VALID                              => 'The Schema Property \'%s.%s\' is not %s %s but %s %s',
43
        self::ERROR_SCHEMA_MAX_PROPERTY_CANNOT_NOT_BE_ZERO                      => 'The Schema Property \'%s.%s\' cannot be zero',
44
        self::ERROR_SCHEMA_PROPERTY_MIN_NOT_BIGGER_THAN_MAX                     => 'The Schema Property \'%s.%s\' with value \'%d\' cannot be greater than Schema Property \'%s.%s\' with value \'%d\'',
45
        self::ERROR_SCHEMA_PROPERTY_REQUIRED_MUST_BE_AN_ARRAY                   => 'The Schema Property \'%s\' is not an array but %s \'%s\'',
46
        self::ERROR_SCHEMA_REQUIRED_AND_PROPERTIES_MUST_MATCH                   => 'The %s: \'%s\' %s defined in \'%s\' but %s not defined in \'%s.properties\'',
47
        self::ERROR_INVALID_REFERENCE                                           => 'Invalid reference; %s',
48
        self::ERROR_NO_LOCAL_DEFINITIONS_HAVE_BEEN_DEFINED                      => 'No local definitions have been defined yet',
49
        self::ERROR_CHECK_IF_LOCAL_DEFINITIONS_EXISTS                           => 'The reference \'%s\' could not be matched to; \'%s\'',
50
        self::ERROR_CURL_NOT_INSTALLED                                          => 'cURL not installed',
51
        self::ERROR_REMOTE_REFERENCE_DOES_NOT_EXIST                             => 'The remote reference \'%s\' does not exist',
52
        self::ERROR_NO_DATA_WAS_FOUND_IN_REMOTE_SCHEMA                          => 'No data found at \'%s\'',
53
        self::ERROR_NO_VALID_JSON_WAS_FOUND_IN_REMOTE_SCHEMA                    => 'No valid JSON Schema found at \'%s\'',
54
        self::ERROR_INPUT_IS_NOT_A_VALID_PREPOSITION                            => '\'%s\' is not a valid preposition',
55
        self::ERROR_SCHEMA_PROPERTY_TYPE_IS_ARRAY_BUT_VALUES_ARE_NOT_UNIQUE     => 'The Schema Property \'%s.%s\' does not contain unique values',
56
        self::ERROR_SCHEMA_PROPERTY_TYPE_IS_ARRAY_BUT_VALUES_AR_NOT_ALL_STRINGS => 'The values of Schema Property \'%s.%s\' are not all of type \'%s\''
57
    ];
58
59
    /**
60
     * prepend classname to clarify error origin
61
     *
62
     * @param int    $code
63
     * @param null   $default
64
     * @param string $msgArray
65
     *
66
     * @return string
67
     */
68
    public function getItemFromVariableArray($code, $default = null, $msgArray = 'messages')
69
    {
70
        return (new \ReflectionClass($this))->getShortName() . ': ' . parent::getItemFromVariableArray($code, $default, $msgArray);
71
    }
72
}
73