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 / microsoft / microsoft-graph / src / Core / Enum.php
ameliabooking / vendor / microsoft / microsoft-graph / src / Core Last commit date
Enum.php 5 years ago ExceptionWrapper.php 6 months ago GraphConstants.php 1 year ago
Enum.php
104 lines
1 <?php
2 /**
3 * Copyright (c) Microsoft Corporation. All Rights Reserved.
4 * Licensed under the MIT License. See License in the project root
5 * for license information.
6 *
7 * Enum File
8 * PHP version 7
9 *
10 * @category Library
11 * @package Microsoft.Graph
12 * @copyright 2016 Microsoft Corporation
13 * @license https://opensource.org/licenses/MIT MIT License
14 * @version GIT: 0.1.0
15 * @link https://graph.microsoft.io/
16 */
17 namespace Microsoft\Graph\Core;
18
19 use Microsoft\Graph\Exception\GraphException;
20
21 /**
22 * Class Enum
23 *
24 * @category Library
25 * @package Microsoft.Graph
26 * @license https://opensource.org/licenses/MIT MIT License
27 * @link https://graph.microsoft.io/
28 */
29 abstract class Enum
30 {
31 private static $constants = [];
32 /**
33 * The value of the enum
34 *
35 * @var string
36 */
37 private $_value;
38
39 /**
40 * Create a new enum
41 *
42 * @param string $value The value of the enum
43 *
44 * @throws GraphException if enum value is invalid
45 */
46 public function __construct($value)
47 {
48 if (!self::has($value)) {
49 throw new GraphException("Invalid enum value $value");
50 }
51 $this->_value = $value;
52 }
53
54 /**
55 * Check if the enum has the given value
56 *
57 * @param string $value
58 * @return bool the enum has the value
59 */
60 public function has($value)
61 {
62 return in_array($value, self::toArray(), true);
63 }
64
65 /**
66 * Check if the enum is defined
67 *
68 * @param string $value the value of the enum
69 *
70 * @return bool True if the value is defined
71 */
72 public function is($value)
73 {
74 return $this->_value === $value;
75 }
76
77 /**
78 * Create a new class for the enum in question
79 *
80 * @return mixed
81 * @throws \ReflectionException
82 */
83 public function toArray()
84 {
85 $class = get_called_class();
86
87 if (!(array_key_exists($class, self::$constants)))
88 {
89 $reflectionObj = new \ReflectionClass($class);
90 self::$constants[$class] = $reflectionObj->getConstants();
91 }
92 return self::$constants[$class];
93 }
94
95 /**
96 * Get the value of the enum
97 *
98 * @return string value of the enum
99 */
100 public function value()
101 {
102 return $this->_value;
103 }
104 }