PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.6
Booking for Appointments and Events Calendar – Amelia v2.4.6
2.4.7 2.4.6 2.4.5 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 / tests / JsonMapperTest / FactoryMethod.php
ameliabooking / vendor / apimatic / jsonmapper / tests / JsonMapperTest Last commit date
Array.php 2 years ago Broken.php 2 years ago ClassWithCtor.php 2 years ago ComplexClassWithCtor.php 2 years ago DependencyInjector.php 2 years ago DerivedClass.php 2 years ago DerivedClass2.php 2 years ago FactoryMethod.php 2 years ago FactoryMethodWithError.php 2 years ago JsonMapperCommentsDiscardedException.php 2 years ago JsonMapperForCheckingAllowedPaths.php 2 years ago Logger.php 2 years ago MapsWithSetters.php 2 years ago Php7TypedClass.php 2 years ago Php7_1TypedClass.php 2 years ago PrivateWithSetter.php 2 years ago Simple.php 2 years ago SimpleBase.php 2 years ago SimpleBaseWithMissingDiscrimType.php 2 years ago ValueObject.php 2 years ago
FactoryMethod.php
121 lines
1 <?php
2 /**
3 * Part of JsonMapper
4 *
5 * PHP version 5
6 *
7 * @package JsonMapper
8 * @author Mehdi Raza <mehdi.jaffery@apimatic.io>
9 * @license OSL-3.0 http://opensource.org/licenses/osl-3.0
10 * @link https://apimatic.io/
11 */
12
13 /**
14 * Unit test helper class for testing property mapping
15 *
16 * @package JsonMapper
17 * @author Mehdi Raza <mehdi.jaffery@apimatic.io>
18 * @license OSL-3.0 http://opensource.org/licenses/osl-3.0
19 * @link https://apimatic.io/
20 */
21 class FactoryMethod
22 {
23 private $privateValue;
24
25 /**
26 * @var string
27 */
28 public $simple;
29
30 /**
31 * @factory FactoryMethod::createFromValue
32 */
33 public $value;
34
35 /**
36 * @var bool
37 * @factory FactoryMethod::createFromInt
38 */
39 public $bool;
40
41 /**
42 * @factory FactoryMethod::createFromTimestamp
43 */
44 public $datetime;
45
46 /**
47 * @factory FactoryMethod::createObjectFromValue
48 */
49 public $object;
50
51 /**
52 * @factory FactoryMethod::createObjectFromValue
53 */
54 public $objObj;
55
56 /**
57 * @var int[]
58 * @factory FactoryMethod::createArrayFromArray
59 */
60 public $array;
61
62 /**
63 * @var int
64 * @factory FactoryMethod::createValueFromArray
65 */
66 public $valueArr;
67
68 /**
69 * @factory FactoryMethod::createFromValue
70 */
71 public function setPrivateValue($val)
72 {
73 $this->privateValue = $val;
74 }
75
76 public function getPrivateValue()
77 {
78 return $this->privateValue;
79 }
80
81 public static function createFromValue($value)
82 {
83 return 'value is ' . $value;
84 }
85
86 public static function createFromInt($value)
87 {
88 return $value === 1;
89 }
90
91 public static function createFromTimestamp($value)
92 {
93 return new DateTime('@' . $value);
94 }
95
96 public static function createObjectFromValue($value)
97 {
98 return new JsonMapperTest_ValueObject($value);
99 }
100
101 public static function createArrayFromArray($value)
102 {
103 return array_map('FactoryMethod::cube', $value);
104 }
105
106 public static function createValueFromArray($value)
107 {
108 $val = 0;
109 for ($i=0; $i < count($value); $i++) {
110 $val += $value[$i];
111 }
112 return $val;
113 }
114
115 public static function cube($n)
116 {
117 return($n * $n);
118 }
119 }
120 ?>
121