-
Notifications
You must be signed in to change notification settings - Fork 1
/
ComplexObject.php
47 lines (40 loc) · 1.04 KB
/
ComplexObject.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
<?php
declare(strict_types=1);
namespace Eclipxe\MicroCatalog\Tests\Fixtures;
use Eclipxe\MicroCatalog\MicroCatalog;
use OutOfRangeException;
/**
* ComplexObject example class
* - Entry values are objects
* - Does not allow undefined indexes
*
* @method string getName()
* @method string getGid()
* @method bool isAdmin()
* @method bool isUser()
*
* @extends MicroCatalog<object>
*/
final class ComplexObject extends MicroCatalog
{
public static function getEntriesArray(): array
{
return [
'Admin' => (object) ['Name' => 'System administrator', 'Gid' => '000'],
'User' => (object) ['Name' => 'Regular user', 'Gid' => '100'],
];
}
protected function getEntryValueWithKey(string $key)
{
$key = ucfirst($key);
return parent::getEntryValueWithKey($key);
}
public function getEntryValueOnUndefined(): object
{
throw new OutOfRangeException('The role is not defined');
}
public function isUndefined(): bool
{
return false;
}
}