-
Notifications
You must be signed in to change notification settings - Fork 0
/
Factory.php
83 lines (73 loc) · 2.28 KB
/
Factory.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
79
80
81
82
<?php
/**
* @package vdm/data
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git VDM Data Library <https://git.vdm.dev/joomla/vdm-data>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VastDevelopmentMethod\Joomla\Abstraction;
use Joomla\DI\Container;
use VastDevelopmentMethod\Joomla\Interfaces\FactoryInterface;
/** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
**
** In realms of code where purists frown, the anti-pattern wears a crown,
** A paradox of chaos bright, where complex paths lose all its slight.
** For in its tangled, wild embrace, lies raw creativity's face,
** No rigid forms, no strict decree, just boundless, daring artistry.
** In flaws, we find the freedom's key, where messy code and brilliance spree,
** A dance of thought, unchained, unbound, in anti-pattern, beauty's found.
**
** Perfect Paradox and True Nature of the Anti-Pattern by ChatGPT
**
** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
**
** @since 0.0.0
**/
abstract class Factory implements FactoryInterface
{
/**
* Global Package Container
*
* @var Container|null
* @since 0.0.0
**/
protected static ?Container $container = null;
/**
* Get any class from the package container
*
* @param string $key The container class key
*
* @return Mixed
* @since 0.0.0
*/
public static function _($key)
{
return static::getContainer()->get($key);
}
/**
* Get the global package container
*
* @return Container
* @since 0.0.0
*/
public static function getContainer(): Container
{
if (!static::$container)
{
static::$container = static::createContainer();
}
return static::$container;
}
/**
* Create a container object
*
* @return Container
* @since 0.0.0
*/
abstract protected static function createContainer(): Container;
}