PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.4
Booking for Appointments and Events Calendar – Amelia v2.4.4
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / apimatic / jsonmapper / src / JsonMapperException.php
ameliabooking / vendor / apimatic / jsonmapper / src Last commit date
AnyOfValidationException.php 1 year ago JsonMapper.php 1 year ago JsonMapperException.php 1 year ago OneOfValidationException.php 1 year ago TypeCombination.php 1 year ago
JsonMapperException.php
188 lines
1 <?php
2
3 /**
4 * Part of JsonMapper
5 *
6 * PHP version 5
7 *
8 * @category Netresearch
9 * @package JsonMapper
10 * @author Christian Weiske <christian.weiske@netresearch.de>
11 * @license OSL-3.0 http://opensource.org/licenses/osl-3.0
12 * @link http://www.netresearch.de/
13 */
14
15 namespace apimatic\jsonmapper;
16
17 use RuntimeException;
18
19 /**
20 * Simple exception
21 *
22 * @category Netresearch
23 * @package JsonMapper
24 * @author Christian Weiske <christian.weiske@netresearch.de>
25 * @license OSL-3.0 http://opensource.org/licenses/osl-3.0
26 * @link http://www.netresearch.de/
27 */
28 class JsonMapperException extends RuntimeException
29 {
30 /**
31 * Exception for discarded comments setting in configuration.
32 *
33 * @param array $concernedKeys Keys (PHP directives) with issues.
34 *
35 * @return JsonMapperException
36 */
37 static function commentsDisabledInConfigurationException($concernedKeys)
38 {
39 return new self(
40 "Comments cannot be discarded in the configuration file i.e." .
41 " the php.ini file; doc comments are a requirement for JsonMapper." .
42 " Following configuration keys must have a value set to \"1\": " .
43 implode(", ", $concernedKeys) . "."
44 );
45 }
46
47 /**
48 * Exception for non-existent key in an object.
49 *
50 * @param string $key The missing key/property.
51 * @param string $class The class in which the key is missing.
52 * @param bool $setterException Raise an exception specific to
53 * missing a setter within the class for
54 * the specified string.
55 *
56 * @return JsonMapperException
57 */
58 static function undefinedPropertyException(
59 $key,
60 $class,
61 $setterException = false
62 ) {
63 $err = $setterException ? 'has no public setter method' : 'does not exist';
64 return new self("JSON property '$key' $err in object of type '$class'");
65 }
66
67 /**
68 * Exception for non-existent key in an object.
69 *
70 * @param string $key The property missing type.
71 * @param string $strClassName The class in which the property is missing type.
72 *
73 * @return JsonMapperException
74 */
75 static function missingTypePropertyException($key, $strClassName)
76 {
77 return new self("Empty type at property '$strClassName::$$key'");
78 }
79
80 /**
81 * Exception for an unCallable Factory Method.
82 *
83 * @param string $factoryMethod The concerned factory method.
84 * @param string $strClassName Related class name.
85 *
86 * @return JsonMapperException
87 */
88 static function unCallableFactoryMethodException($factoryMethod, $strClassName)
89 {
90 return new self(
91 "Factory method '$factoryMethod' referenced by " .
92 "'$strClassName' is not callable."
93 );
94 }
95
96 /**
97 * Exception for not able to call factory method with the given value.
98 *
99 * @param string $argType Type of the argument passed in method.
100 * @param string $reasons Exception message received from factory method.
101 *
102 * @return JsonMapperException
103 */
104 static function invalidArgumentFactoryMethodException($argType, $reasons)
105 {
106 return new self(
107 "Provided factory methods are not callable with " .
108 "the value of Type: $argType\n$reasons"
109 );
110 }
111
112 /**
113 * Exception when it is not possible to map an object to a specific type.
114 *
115 * @param string $typeName Name of type to map json object on.
116 * @param string $typeGroup Group name of the type provided.
117 * @param string $value Value that should be mapped by typeGroup
118 * i.e. JSON string.
119 *
120 * @return JsonMapperException
121 */
122 static function unableToMapException($typeName, $typeGroup, $value)
123 {
124 return new self("Unable to map $typeName: $typeGroup on: $value");
125 }
126
127 /**
128 * A property marked as required was missing in the object provided.
129 *
130 * @param string $propertyName Concerned property's name.
131 * @param string $className The class name in which the property wasn't found.
132 *
133 * @return JsonMapperException
134 */
135 static function requiredPropertyMissingException($propertyName, $className)
136 {
137 return new self(
138 "Required property '$propertyName' of class " .
139 "'$className' is missing in JSON data"
140 );
141 }
142
143 /**
144 * No required arguments were provided.
145 *
146 * @param string $class The concerned class name.
147 * @param int $ctorReqParamNumber The number of req params in constructor.
148 *
149 * @return JsonMapperException
150 */
151 static function noArgumentsException($class, $ctorReqParamNumber)
152 {
153 return new self(
154 "$class class requires $ctorReqParamNumber "
155 . "arguments in constructor but none provided"
156 );
157 }
158
159 /**
160 * Provided arguments were less than required.
161 *
162 * @param string $class The concerned class name.
163 * @param array $ctorRequiredParamsName Required parameters array.
164 *
165 * @return JsonMapperException
166 */
167 static function fewerArgumentsException($class, $ctorRequiredParamsName)
168 {
169 return new self(
170 "Could not find required constructor arguments for $class: "
171 . implode(", ", $ctorRequiredParamsName)
172 );
173 }
174
175 /**
176 * Provided type was not applicable on the given value.
177 *
178 * @param string $type The type value could not be mapped to.
179 * @param string $value Concerned value.
180 *
181 * @return JsonMapperException
182 */
183 static function unableToSetTypeException($type, $value)
184 {
185 return new self("Could not set type '$type' on value: $value");
186 }
187 }
188