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 / core / src / TestCase / TestParam.php
ameliabooking / vendor / apimatic / core / src / TestCase Last commit date
BodyMatchers 1 year ago CoreTestCase.php 1 year ago HeadersMatcher.php 1 year ago StatusCodeMatcher.php 1 year ago TestParam.php 1 year ago
TestParam.php
84 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Core\TestCase;
6
7 use apimatic\jsonmapper\JsonMapperException;
8 use Closure;
9 use Core\Client;
10 use Core\Types\Sdk\CoreFileWrapper;
11 use Core\Utils\CoreHelper;
12 use Exception;
13
14 class TestParam
15 {
16 /**
17 * Returns a typeGroup type TestParam.
18 *
19 * @param string $json Json value to be mapped by the typeGroup
20 * @param string $typeGroup Group of types in string format i.e. oneOf(...), anyOf(...)
21 * @param array $deserializers Methods required for the de-serialization of specific types in
22 * in the provided typeGroup, should be an array in the format:
23 * ['path/to/method returnType', ...]. Default: []
24 * @return mixed Returns the mapped value from json
25 * @throws JsonMapperException
26 */
27 public static function typeGroup(string $json, string $typeGroup, array $deserializers = [])
28 {
29 return Client::getJsonHelper()->mapTypes(CoreHelper::deserialize($json, false), $typeGroup, $deserializers);
30 }
31
32 /**
33 * Returns an object type TestParam.
34 *
35 * @param string $json Json value to be mapped by the class
36 * @param string|null $classname Name of the class inclusive of its namespace,
37 * Default: object
38 * @param int $dimension Greater than 0 if trying to map an array of
39 * class with some dimensions, Default: 0
40 * @return mixed Returns the mapped value from json
41 * @throws Exception
42 */
43 public static function object(string $json, ?string $classname = null, int $dimension = 0)
44 {
45 if (is_null($classname)) {
46 return CoreHelper::deserialize($json);
47 }
48 return Client::getJsonHelper()->mapClass(CoreHelper::deserialize($json, false), $classname, $dimension);
49 }
50
51 /**
52 * Returns a custom TestParam.
53 *
54 * @param string $json Json value to be deserialized using custom callback
55 * @param callable $callback Callback use to deserialize the given value
56 * @return mixed Returns the result from the callback
57 */
58 public static function custom(string $json, callable $callback)
59 {
60 return Closure::fromCallable($callback)(CoreHelper::deserialize($json, false));
61 }
62
63 /**
64 * Returns a file type TestParam.
65 *
66 * @param string $url URL of the file to download
67 */
68 public static function file(string $url)
69 {
70 $realPath = CoreFileWrapper::getDownloadedRealFilePath($url);
71 return self::localFile($realPath);
72 }
73
74 /**
75 * Returns a localFile TestParam.
76 *
77 * @param string $realPath Local path to the file
78 */
79 public static function localFile(string $realPath)
80 {
81 return Client::getConverter()->createFileWrapper($realPath, null, '');
82 }
83 }
84