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
|
<?php /** * Final class AmpWpPluginFactory. * * @package AmpProject\AmpWP */
namespace AmpProject\AmpWP;
use AmpProject\AmpWP\Infrastructure\Plugin;
/** * The plugin factory is responsible for instantiating the plugin and returning * that instance. * * It can decide whether to return a shared or a fresh instance as needed. * * To read more about why this is preferable to a Singleton, * * @see https://www.alainschlesser.com/singletons-shared-instances/ * @since 2.0 * @internal */ final class AmpWpPluginFactory {
/** * Create and return an instance of the plugin. * * This always returns a shared instance. This way, outside code can always * get access to the object instance of the plugin. * * @return Plugin Plugin instance. */ public static function create() { static $plugin = null;
if ( null === $plugin ) { $plugin = new AmpWpPlugin(); }
return $plugin; } }
|