-
Notifications
You must be signed in to change notification settings - Fork 12
/
quaderno_class.php
executable file
·78 lines (71 loc) · 1.23 KB
/
quaderno_class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
* Quaderno Class
*
* @package Quaderno PHP
* @author Quaderno <[email protected]>
* @copyright Copyright (c) 2021, Quaderno
* @license https://opensource.org/licenses/MIT The MIT License
*/
/* Interface that implements every single class */
#[AllowDynamicProperties]
abstract class QuadernoClass implements \JsonSerializable
{
/**
* @var array
*/
protected $data = array();
/**
* @param array $newdata
*/
public function __construct($newdata)
{
if (is_array($newdata)) $this->data = $newdata;
}
/**
* @param string $name
* @param mixed $value
*
* @return void
*/
public function __set($name, $value)
{
$this->data[$name] = $value;
}
/**
* @param string $name
*
* @return mixed
*/
public function __get($name)
{
return array_key_exists($name, $this->data) ? $this->data[$name] : null;
}
/**
* @param string $name
*
* @return bool
*/
public function __isset($name)
{
return array_key_exists($name, $this->data);
}
/**
* @return array
*/
protected function getArray()
{
return $this->data;
}
/**
* Specify data which should be serialized to JSON.
*
* @return array
*/
#[ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->data;
}
}
?>