Completed
Pull Request — master (#378)
by Darren
13:52
created
core/services/loaders/Loader.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@
 block discarded – undo
101 101
 
102 102
 
103 103
     /**
104
-     * @param FullyQualifiedName|string $fqcn
104
+     * @param string $fqcn
105 105
      * @param array                     $arguments
106 106
      * @return mixed
107 107
      */
Please login to merge, or discard this patch.
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -15,115 +15,115 @@
 block discarded – undo
15 15
 class Loader implements LoaderInterface
16 16
 {
17 17
 
18
-    /**
19
-     * @var LoaderDecoratorInterface $new_loader
20
-     */
21
-    private $new_loader;
22
-
23
-    /**
24
-     * @var LoaderDecoratorInterface $shared_loader
25
-     */
26
-    private $shared_loader;
27
-
28
-    /**
29
-     * @var ClassInterfaceCache $class_cache
30
-     */
31
-    private $class_cache;
32
-
33
-    /**
34
-     * Loader constructor.
35
-     *
36
-     * @param LoaderDecoratorInterface        $new_loader
37
-     * @param CachingLoaderDecoratorInterface $shared_loader
38
-     * @param ClassInterfaceCache             $class_cache
39
-     */
40
-    public function __construct(
41
-        LoaderDecoratorInterface $new_loader,
42
-        CachingLoaderDecoratorInterface $shared_loader,
43
-        ClassInterfaceCache $class_cache
44
-    ) {
45
-        $this->new_loader    = $new_loader;
46
-        $this->shared_loader = $shared_loader;
47
-        $this->class_cache   = $class_cache;
48
-    }
49
-
50
-
51
-    /**
52
-     * @return LoaderDecoratorInterface
53
-     */
54
-    public function getNewLoader()
55
-    {
56
-        return $this->new_loader;
57
-    }
58
-
59
-
60
-    /**
61
-     * @return CachingLoaderDecoratorInterface
62
-     */
63
-    public function getSharedLoader()
64
-    {
65
-        return $this->shared_loader;
66
-    }
67
-
68
-
69
-    /**
70
-     * @param FullyQualifiedName|string $fqcn
71
-     * @param array                     $arguments
72
-     * @param bool                      $shared
73
-     * @return mixed
74
-     */
75
-    public function load($fqcn, array $arguments = array(), $shared = true)
76
-    {
77
-        $fqcn = $this->class_cache->getFqn($fqcn);
78
-        if ($this->class_cache->hasInterface($fqcn, 'EventEspresso\core\interfaces\ReservedInstanceInterface')) {
79
-            $shared = true;
80
-        }
81
-        return $shared
82
-            ? $this->getSharedLoader()->load($fqcn, $arguments, $shared)
83
-            : $this->getNewLoader()->load($fqcn, $arguments, $shared);
84
-    }
85
-
86
-
87
-    /**
88
-     * @param FullyQualifiedName|string $fqcn
89
-     * @param array                     $arguments
90
-     * @return mixed
91
-     */
92
-    public function getNew($fqcn, array $arguments = array())
93
-    {
94
-        return $this->load($fqcn, $arguments, false);
95
-    }
96
-
97
-
98
-    /**
99
-     * @param FullyQualifiedName|string $fqcn
100
-     * @param array                     $arguments
101
-     * @return mixed
102
-     */
103
-    public function getShared($fqcn, array $arguments = array())
104
-    {
105
-        return $this->load($fqcn, $arguments);
106
-    }
107
-
108
-
109
-    /**
110
-     * @param FullyQualifiedName|string $fqcn
111
-     * @param mixed                     $object
112
-     * @return bool
113
-     * @throws InvalidArgumentException
114
-     */
115
-    public function share($fqcn, $object)
116
-    {
117
-        $fqcn = $this->class_cache->getFqn($fqcn);
118
-        return $this->getSharedLoader()->share($fqcn, $object);
119
-    }
120
-
121
-
122
-    /**
123
-     * calls reset() on loaders if that method exists
124
-     */
125
-    public function reset()
126
-    {
127
-        $this->shared_loader->reset();
128
-    }
18
+	/**
19
+	 * @var LoaderDecoratorInterface $new_loader
20
+	 */
21
+	private $new_loader;
22
+
23
+	/**
24
+	 * @var LoaderDecoratorInterface $shared_loader
25
+	 */
26
+	private $shared_loader;
27
+
28
+	/**
29
+	 * @var ClassInterfaceCache $class_cache
30
+	 */
31
+	private $class_cache;
32
+
33
+	/**
34
+	 * Loader constructor.
35
+	 *
36
+	 * @param LoaderDecoratorInterface        $new_loader
37
+	 * @param CachingLoaderDecoratorInterface $shared_loader
38
+	 * @param ClassInterfaceCache             $class_cache
39
+	 */
40
+	public function __construct(
41
+		LoaderDecoratorInterface $new_loader,
42
+		CachingLoaderDecoratorInterface $shared_loader,
43
+		ClassInterfaceCache $class_cache
44
+	) {
45
+		$this->new_loader    = $new_loader;
46
+		$this->shared_loader = $shared_loader;
47
+		$this->class_cache   = $class_cache;
48
+	}
49
+
50
+
51
+	/**
52
+	 * @return LoaderDecoratorInterface
53
+	 */
54
+	public function getNewLoader()
55
+	{
56
+		return $this->new_loader;
57
+	}
58
+
59
+
60
+	/**
61
+	 * @return CachingLoaderDecoratorInterface
62
+	 */
63
+	public function getSharedLoader()
64
+	{
65
+		return $this->shared_loader;
66
+	}
67
+
68
+
69
+	/**
70
+	 * @param FullyQualifiedName|string $fqcn
71
+	 * @param array                     $arguments
72
+	 * @param bool                      $shared
73
+	 * @return mixed
74
+	 */
75
+	public function load($fqcn, array $arguments = array(), $shared = true)
76
+	{
77
+		$fqcn = $this->class_cache->getFqn($fqcn);
78
+		if ($this->class_cache->hasInterface($fqcn, 'EventEspresso\core\interfaces\ReservedInstanceInterface')) {
79
+			$shared = true;
80
+		}
81
+		return $shared
82
+			? $this->getSharedLoader()->load($fqcn, $arguments, $shared)
83
+			: $this->getNewLoader()->load($fqcn, $arguments, $shared);
84
+	}
85
+
86
+
87
+	/**
88
+	 * @param FullyQualifiedName|string $fqcn
89
+	 * @param array                     $arguments
90
+	 * @return mixed
91
+	 */
92
+	public function getNew($fqcn, array $arguments = array())
93
+	{
94
+		return $this->load($fqcn, $arguments, false);
95
+	}
96
+
97
+
98
+	/**
99
+	 * @param FullyQualifiedName|string $fqcn
100
+	 * @param array                     $arguments
101
+	 * @return mixed
102
+	 */
103
+	public function getShared($fqcn, array $arguments = array())
104
+	{
105
+		return $this->load($fqcn, $arguments);
106
+	}
107
+
108
+
109
+	/**
110
+	 * @param FullyQualifiedName|string $fqcn
111
+	 * @param mixed                     $object
112
+	 * @return bool
113
+	 * @throws InvalidArgumentException
114
+	 */
115
+	public function share($fqcn, $object)
116
+	{
117
+		$fqcn = $this->class_cache->getFqn($fqcn);
118
+		return $this->getSharedLoader()->share($fqcn, $object);
119
+	}
120
+
121
+
122
+	/**
123
+	 * calls reset() on loaders if that method exists
124
+	 */
125
+	public function reset()
126
+	{
127
+		$this->shared_loader->reset();
128
+	}
129 129
 }
Please login to merge, or discard this patch.
core/services/bootstrap/BootstrapDependencyInjectionContainer.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -78,13 +78,13 @@
 block discarded – undo
78 78
         // EE_Dependency_Map: info about how to load classes required by other classes
79 79
         espresso_load_required(
80 80
             'EE_Dependency_Map',
81
-            EE_CORE . 'EE_Dependency_Map.core.php'
81
+            EE_CORE.'EE_Dependency_Map.core.php'
82 82
         );
83 83
         $this->dependency_map = EE_Dependency_Map::instance($this->class_cache);
84 84
         // EE_Registry: central repository for classes (legacy)
85 85
         espresso_load_required(
86 86
             'EE_Registry',
87
-            EE_CORE . 'EE_Registry.core.php'
87
+            EE_CORE.'EE_Registry.core.php'
88 88
         );
89 89
         $this->registry = EE_Registry::instance(
90 90
             $this->dependency_map,
Please login to merge, or discard this patch.
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -25,124 +25,124 @@
 block discarded – undo
25 25
 class BootstrapDependencyInjectionContainer
26 26
 {
27 27
 
28
-    /**
29
-     * @var EE_Dependency_Map $dependency_map
30
-     */
31
-    protected $dependency_map;
32
-
33
-    /**
34
-     * @type LoaderInterface $loader
35
-     */
36
-    protected $loader;
37
-
38
-    /**
39
-     * @var EE_Registry $registry
40
-     */
41
-    protected $registry;
42
-
43
-    /**
44
-     * @var ClassInterfaceCache $class_cache
45
-     */
46
-    private $class_cache;
47
-
48
-    /**
49
-     * @var Mirror
50
-     */
51
-    private $mirror;
52
-
53
-    /**
54
-     * @var ObjectIdentifier
55
-     */
56
-    private $object_identifier;
57
-
58
-
59
-    /**
60
-     * Can't use this just yet until we exorcise some more of our singleton usage from core
61
-     */
62
-    public function buildDependencyInjectionContainer()
63
-    {
64
-        // build DI container
65
-        // $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop();
66
-        // $OpenCoffeeShop->addRecipes();
67
-        // $CoffeeShop = $OpenCoffeeShop->CoffeeShop();
68
-    }
69
-
70
-
71
-    /**
72
-     * Setups  EE_Registry and EE_Dependency_Map
73
-     *
74
-     * @throws EE_Error
75
-     */
76
-    public function buildLegacyDependencyInjectionContainer()
77
-    {
78
-        $this->class_cache = new ClassInterfaceCache();
79
-        $this->object_identifier = new ObjectIdentifier($this->class_cache);
80
-        $this->mirror = new Mirror();
81
-        // EE_Dependency_Map: info about how to load classes required by other classes
82
-        espresso_load_required(
83
-            'EE_Dependency_Map',
84
-            EE_CORE . 'EE_Dependency_Map.core.php'
85
-        );
86
-        $this->dependency_map = EE_Dependency_Map::instance($this->class_cache);
87
-        // EE_Registry: central repository for classes (legacy)
88
-        espresso_load_required(
89
-            'EE_Registry',
90
-            EE_CORE . 'EE_Registry.core.php'
91
-        );
92
-        $this->registry = EE_Registry::instance(
93
-            $this->dependency_map,
94
-            $this->mirror,
95
-            $this->class_cache,
96
-            $this->object_identifier
97
-        );
98
-
99
-    }
100
-
101
-
102
-    /**
103
-     * Performs initial setup for the generic Loader
104
-     *
105
-     * @throws InvalidDataTypeException
106
-     * @throws InvalidInterfaceException
107
-     * @throws InvalidArgumentException
108
-     */
109
-    public function buildLoader()
110
-    {
111
-        $this->loader = LoaderFactory::getLoader(
112
-            $this->registry,
113
-            $this->class_cache,
114
-            $this->object_identifier
115
-        );
116
-        $this->loader->share('EventEspresso\core\services\loaders\ClassInterfaceCache', $this->class_cache);
117
-        $this->loader->share('EventEspresso\core\services\loaders\ObjectIdentifier', $this->object_identifier);
118
-        $this->loader->share('EventEspresso\core\services\container\Mirror', $this->mirror);
119
-        $this->dependency_map->setLoader($this->loader);
120
-    }
121
-
122
-
123
-    /**
124
-     * @return EE_Dependency_Map
125
-     */
126
-    public function getDependencyMap()
127
-    {
128
-        return $this->dependency_map;
129
-    }
130
-
131
-
132
-    /**
133
-     * @return EE_Registry
134
-     */
135
-    public function getRegistry()
136
-    {
137
-        return $this->registry;
138
-    }
139
-
140
-
141
-    /**
142
-     * @return LoaderInterface
143
-     */
144
-    public function getLoader()
145
-    {
146
-        return $this->loader;
147
-    }
28
+	/**
29
+	 * @var EE_Dependency_Map $dependency_map
30
+	 */
31
+	protected $dependency_map;
32
+
33
+	/**
34
+	 * @type LoaderInterface $loader
35
+	 */
36
+	protected $loader;
37
+
38
+	/**
39
+	 * @var EE_Registry $registry
40
+	 */
41
+	protected $registry;
42
+
43
+	/**
44
+	 * @var ClassInterfaceCache $class_cache
45
+	 */
46
+	private $class_cache;
47
+
48
+	/**
49
+	 * @var Mirror
50
+	 */
51
+	private $mirror;
52
+
53
+	/**
54
+	 * @var ObjectIdentifier
55
+	 */
56
+	private $object_identifier;
57
+
58
+
59
+	/**
60
+	 * Can't use this just yet until we exorcise some more of our singleton usage from core
61
+	 */
62
+	public function buildDependencyInjectionContainer()
63
+	{
64
+		// build DI container
65
+		// $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop();
66
+		// $OpenCoffeeShop->addRecipes();
67
+		// $CoffeeShop = $OpenCoffeeShop->CoffeeShop();
68
+	}
69
+
70
+
71
+	/**
72
+	 * Setups  EE_Registry and EE_Dependency_Map
73
+	 *
74
+	 * @throws EE_Error
75
+	 */
76
+	public function buildLegacyDependencyInjectionContainer()
77
+	{
78
+		$this->class_cache = new ClassInterfaceCache();
79
+		$this->object_identifier = new ObjectIdentifier($this->class_cache);
80
+		$this->mirror = new Mirror();
81
+		// EE_Dependency_Map: info about how to load classes required by other classes
82
+		espresso_load_required(
83
+			'EE_Dependency_Map',
84
+			EE_CORE . 'EE_Dependency_Map.core.php'
85
+		);
86
+		$this->dependency_map = EE_Dependency_Map::instance($this->class_cache);
87
+		// EE_Registry: central repository for classes (legacy)
88
+		espresso_load_required(
89
+			'EE_Registry',
90
+			EE_CORE . 'EE_Registry.core.php'
91
+		);
92
+		$this->registry = EE_Registry::instance(
93
+			$this->dependency_map,
94
+			$this->mirror,
95
+			$this->class_cache,
96
+			$this->object_identifier
97
+		);
98
+
99
+	}
100
+
101
+
102
+	/**
103
+	 * Performs initial setup for the generic Loader
104
+	 *
105
+	 * @throws InvalidDataTypeException
106
+	 * @throws InvalidInterfaceException
107
+	 * @throws InvalidArgumentException
108
+	 */
109
+	public function buildLoader()
110
+	{
111
+		$this->loader = LoaderFactory::getLoader(
112
+			$this->registry,
113
+			$this->class_cache,
114
+			$this->object_identifier
115
+		);
116
+		$this->loader->share('EventEspresso\core\services\loaders\ClassInterfaceCache', $this->class_cache);
117
+		$this->loader->share('EventEspresso\core\services\loaders\ObjectIdentifier', $this->object_identifier);
118
+		$this->loader->share('EventEspresso\core\services\container\Mirror', $this->mirror);
119
+		$this->dependency_map->setLoader($this->loader);
120
+	}
121
+
122
+
123
+	/**
124
+	 * @return EE_Dependency_Map
125
+	 */
126
+	public function getDependencyMap()
127
+	{
128
+		return $this->dependency_map;
129
+	}
130
+
131
+
132
+	/**
133
+	 * @return EE_Registry
134
+	 */
135
+	public function getRegistry()
136
+	{
137
+		return $this->registry;
138
+	}
139
+
140
+
141
+	/**
142
+	 * @return LoaderInterface
143
+	 */
144
+	public function getLoader()
145
+	{
146
+		return $this->loader;
147
+	}
148 148
 }
Please login to merge, or discard this patch.
core/domain/values/FullyQualifiedName.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -21,54 +21,54 @@
 block discarded – undo
21 21
 class FullyQualifiedName
22 22
 {
23 23
 
24
-    /**
25
-     * @var string $fully_qualified_name
26
-     */
27
-    private $fully_qualified_name;
24
+	/**
25
+	 * @var string $fully_qualified_name
26
+	 */
27
+	private $fully_qualified_name;
28 28
 
29 29
 
30
-    /**
31
-     * FullyQualifiedName constructor.
32
-     *
33
-     * @param string $fully_qualified_name
34
-     * @throws InvalidClassException
35
-     * @throws InvalidInterfaceException
36
-     * @throws InvalidDataTypeException
37
-     */
38
-    public function __construct($fully_qualified_name)
39
-    {
40
-        if (! is_string($fully_qualified_name)) {
41
-            throw new InvalidDataTypeException(
42
-                '$fully_qualified_name',
43
-                $fully_qualified_name,
44
-                'string'
45
-            );
46
-        }
47
-        if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) {
48
-            if (strpos($fully_qualified_name, 'Interface') !== false) {
49
-                throw new InvalidInterfaceException($fully_qualified_name);
50
-            }
51
-            throw new InvalidClassException($fully_qualified_name);
52
-        }
53
-        $this->fully_qualified_name = $fully_qualified_name;
54
-    }
30
+	/**
31
+	 * FullyQualifiedName constructor.
32
+	 *
33
+	 * @param string $fully_qualified_name
34
+	 * @throws InvalidClassException
35
+	 * @throws InvalidInterfaceException
36
+	 * @throws InvalidDataTypeException
37
+	 */
38
+	public function __construct($fully_qualified_name)
39
+	{
40
+		if (! is_string($fully_qualified_name)) {
41
+			throw new InvalidDataTypeException(
42
+				'$fully_qualified_name',
43
+				$fully_qualified_name,
44
+				'string'
45
+			);
46
+		}
47
+		if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) {
48
+			if (strpos($fully_qualified_name, 'Interface') !== false) {
49
+				throw new InvalidInterfaceException($fully_qualified_name);
50
+			}
51
+			throw new InvalidClassException($fully_qualified_name);
52
+		}
53
+		$this->fully_qualified_name = $fully_qualified_name;
54
+	}
55 55
 
56 56
 
57
-    /**
58
-     * @return string
59
-     */
60
-    public function string()
61
-    {
62
-        return $this->fully_qualified_name;
63
-    }
57
+	/**
58
+	 * @return string
59
+	 */
60
+	public function string()
61
+	{
62
+		return $this->fully_qualified_name;
63
+	}
64 64
 
65 65
 
66
-    /**
67
-     * @return string
68
-     */
69
-    public function __toString()
70
-    {
71
-        return $this->fully_qualified_name;
72
-    }
66
+	/**
67
+	 * @return string
68
+	 */
69
+	public function __toString()
70
+	{
71
+		return $this->fully_qualified_name;
72
+	}
73 73
 
74 74
 }
Please login to merge, or discard this patch.
core/services/loaders/CoreLoader.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
      */
48 48
     public function __construct($generator)
49 49
     {
50
-        if (! ($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) {
50
+        if ( ! ($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) {
51 51
             throw new InvalidArgumentException(
52 52
                 esc_html__(
53 53
                     'The CoreLoader class must receive an instance of EE_Registry or the CoffeeShop DI container.',
Please login to merge, or discard this patch.
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -29,108 +29,108 @@
 block discarded – undo
29 29
 class CoreLoader implements LoaderDecoratorInterface
30 30
 {
31 31
 
32
-    /**
33
-     * @var EE_Registry|CoffeeShop $generator
34
-     */
35
-    private $generator;
32
+	/**
33
+	 * @var EE_Registry|CoffeeShop $generator
34
+	 */
35
+	private $generator;
36 36
 
37 37
 
38
-    /**
39
-     * CoreLoader constructor.
40
-     *
41
-     * @param EE_Registry|CoffeeShop $generator
42
-     * @throws InvalidArgumentException
43
-     */
44
-    public function __construct($generator)
45
-    {
46
-        if (! ($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) {
47
-            throw new InvalidArgumentException(
48
-                esc_html__(
49
-                    'The CoreLoader class must receive an instance of EE_Registry or the CoffeeShop DI container.',
50
-                    'event_espresso'
51
-                )
52
-            );
53
-        }
54
-        $this->generator = $generator;
55
-    }
38
+	/**
39
+	 * CoreLoader constructor.
40
+	 *
41
+	 * @param EE_Registry|CoffeeShop $generator
42
+	 * @throws InvalidArgumentException
43
+	 */
44
+	public function __construct($generator)
45
+	{
46
+		if (! ($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) {
47
+			throw new InvalidArgumentException(
48
+				esc_html__(
49
+					'The CoreLoader class must receive an instance of EE_Registry or the CoffeeShop DI container.',
50
+					'event_espresso'
51
+				)
52
+			);
53
+		}
54
+		$this->generator = $generator;
55
+	}
56 56
 
57 57
 
58
-    /**
59
-     * Calls the appropriate loading method from the installed generator;
60
-     * If EE_Registry is being used, then the additional parameters for the EE_Registry::create() method
61
-     * can be added to the $arguments array and they will be extracted and passed to EE_Registry::create(),
62
-     * but NOT to the class being instantiated.
63
-     * This is done by adding the parameters to the $arguments array as follows:
64
-     *  array(
65
-     *      'EE_Registry::create(from_db)'   => true, // boolean value, default = false
66
-     *      'EE_Registry::create(load_only)' => true, // boolean value, default = false
67
-     *      'EE_Registry::create(addon)'     => true, // boolean value, default = false
68
-     *  )
69
-     *
70
-     * @param string $fqcn
71
-     * @param array  $arguments
72
-     * @param bool   $shared
73
-     * @return mixed
74
-     * @throws OutOfBoundsException
75
-     * @throws ServiceExistsException
76
-     * @throws InstantiationException
77
-     * @throws InvalidIdentifierException
78
-     * @throws InvalidDataTypeException
79
-     * @throws InvalidClassException
80
-     * @throws EE_Error
81
-     * @throws ServiceNotFoundException
82
-     * @throws ReflectionException
83
-     * @throws InvalidInterfaceException
84
-     * @throws InvalidArgumentException
85
-     */
86
-    public function load($fqcn, $arguments = array(), $shared = true)
87
-    {
88
-        $shared = filter_var($shared, FILTER_VALIDATE_BOOLEAN);
89
-        if ($this->generator instanceof EE_Registry) {
90
-            // check if additional EE_Registry::create() arguments have been passed
91
-            // from_db
92
-            $from_db = isset($arguments['EE_Registry::create(from_db)'])
93
-                ? filter_var($arguments['EE_Registry::create(from_db)'], FILTER_VALIDATE_BOOLEAN)
94
-                : false;
95
-            // load_only
96
-            $load_only = isset($arguments['EE_Registry::create(load_only)'])
97
-                ? filter_var($arguments['EE_Registry::create(load_only)'], FILTER_VALIDATE_BOOLEAN)
98
-                : false;
99
-            // addon
100
-            $addon = isset($arguments['EE_Registry::create(addon)'])
101
-                ? filter_var($arguments['EE_Registry::create(addon)'], FILTER_VALIDATE_BOOLEAN)
102
-                : false;
103
-            unset(
104
-                $arguments['EE_Registry::create(from_db)'],
105
-                $arguments['EE_Registry::create(load_only)'],
106
-                $arguments['EE_Registry::create(addon)']
107
-            );
108
-            // addons need to be cached on EE_Registry
109
-            $shared = $addon ? true : $shared;
110
-            return $this->generator->create(
111
-                $fqcn,
112
-                $arguments,
113
-                $shared,
114
-                $from_db,
115
-                $load_only,
116
-                $addon
117
-            );
118
-        }
119
-        return $this->generator->brew(
120
-            $fqcn,
121
-            $arguments,
122
-            $shared ? CoffeeMaker::BREW_SHARED : CoffeeMaker::BREW_NEW
123
-        );
124
-    }
58
+	/**
59
+	 * Calls the appropriate loading method from the installed generator;
60
+	 * If EE_Registry is being used, then the additional parameters for the EE_Registry::create() method
61
+	 * can be added to the $arguments array and they will be extracted and passed to EE_Registry::create(),
62
+	 * but NOT to the class being instantiated.
63
+	 * This is done by adding the parameters to the $arguments array as follows:
64
+	 *  array(
65
+	 *      'EE_Registry::create(from_db)'   => true, // boolean value, default = false
66
+	 *      'EE_Registry::create(load_only)' => true, // boolean value, default = false
67
+	 *      'EE_Registry::create(addon)'     => true, // boolean value, default = false
68
+	 *  )
69
+	 *
70
+	 * @param string $fqcn
71
+	 * @param array  $arguments
72
+	 * @param bool   $shared
73
+	 * @return mixed
74
+	 * @throws OutOfBoundsException
75
+	 * @throws ServiceExistsException
76
+	 * @throws InstantiationException
77
+	 * @throws InvalidIdentifierException
78
+	 * @throws InvalidDataTypeException
79
+	 * @throws InvalidClassException
80
+	 * @throws EE_Error
81
+	 * @throws ServiceNotFoundException
82
+	 * @throws ReflectionException
83
+	 * @throws InvalidInterfaceException
84
+	 * @throws InvalidArgumentException
85
+	 */
86
+	public function load($fqcn, $arguments = array(), $shared = true)
87
+	{
88
+		$shared = filter_var($shared, FILTER_VALIDATE_BOOLEAN);
89
+		if ($this->generator instanceof EE_Registry) {
90
+			// check if additional EE_Registry::create() arguments have been passed
91
+			// from_db
92
+			$from_db = isset($arguments['EE_Registry::create(from_db)'])
93
+				? filter_var($arguments['EE_Registry::create(from_db)'], FILTER_VALIDATE_BOOLEAN)
94
+				: false;
95
+			// load_only
96
+			$load_only = isset($arguments['EE_Registry::create(load_only)'])
97
+				? filter_var($arguments['EE_Registry::create(load_only)'], FILTER_VALIDATE_BOOLEAN)
98
+				: false;
99
+			// addon
100
+			$addon = isset($arguments['EE_Registry::create(addon)'])
101
+				? filter_var($arguments['EE_Registry::create(addon)'], FILTER_VALIDATE_BOOLEAN)
102
+				: false;
103
+			unset(
104
+				$arguments['EE_Registry::create(from_db)'],
105
+				$arguments['EE_Registry::create(load_only)'],
106
+				$arguments['EE_Registry::create(addon)']
107
+			);
108
+			// addons need to be cached on EE_Registry
109
+			$shared = $addon ? true : $shared;
110
+			return $this->generator->create(
111
+				$fqcn,
112
+				$arguments,
113
+				$shared,
114
+				$from_db,
115
+				$load_only,
116
+				$addon
117
+			);
118
+		}
119
+		return $this->generator->brew(
120
+			$fqcn,
121
+			$arguments,
122
+			$shared ? CoffeeMaker::BREW_SHARED : CoffeeMaker::BREW_NEW
123
+		);
124
+	}
125 125
 
126 126
 
127
-    /**
128
-     * calls reset() on generator if method exists
129
-     */
130
-    public function reset()
131
-    {
132
-        if ($this->generator instanceof ResettableInterface) {
133
-            $this->generator->reset();
134
-        }
135
-    }
127
+	/**
128
+	 * calls reset() on generator if method exists
129
+	 */
130
+	public function reset()
131
+	{
132
+		if ($this->generator instanceof ResettableInterface) {
133
+			$this->generator->reset();
134
+		}
135
+	}
136 136
 }
Please login to merge, or discard this patch.
core/services/loaders/CachingLoader.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         $identifier = ''
54 54
     ) {
55 55
         parent::__construct($loader);
56
-        $this->cache       = $cache;
56
+        $this->cache = $cache;
57 57
         $this->object_identifier = $object_identifier;
58 58
         $this->setIdentifier($identifier);
59 59
         if ($this->identifier !== '') {
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      */
90 90
     private function setIdentifier($identifier)
91 91
     {
92
-        if (! is_string($identifier)) {
92
+        if ( ! is_string($identifier)) {
93 93
             throw new InvalidDataTypeException('$identifier', $identifier, 'string');
94 94
         }
95 95
         $this->identifier = $identifier;
Please login to merge, or discard this patch.
Indentation   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -17,154 +17,154 @@
 block discarded – undo
17 17
 class CachingLoader extends CachingLoaderDecorator
18 18
 {
19 19
 
20
-    /**
21
-     * @var string $identifier
22
-     */
23
-    protected $identifier;
24
-
25
-    /**
26
-     * @var CollectionInterface $cache
27
-     */
28
-    protected $cache;
29
-
30
-    /**
31
-     * @var ObjectIdentifier
32
-     */
33
-    private $object_identifier;
34
-
35
-
36
-    /**
37
-     * CachingLoader constructor.
38
-     *
39
-     * @param LoaderDecoratorInterface $loader
40
-     * @param CollectionInterface      $cache
41
-     * @param ObjectIdentifier         $object_identifier
42
-     * @param string                   $identifier
43
-     * @throws InvalidDataTypeException
44
-     */
45
-    public function __construct(
46
-        LoaderDecoratorInterface $loader,
47
-        CollectionInterface $cache,
48
-        ObjectIdentifier $object_identifier,
49
-        $identifier = ''
50
-    ) {
51
-        parent::__construct($loader);
52
-        $this->cache       = $cache;
53
-        $this->object_identifier = $object_identifier;
54
-        $this->setIdentifier($identifier);
55
-        if ($this->identifier !== '') {
56
-            // to only clear this cache, and assuming an identifier has been set, simply do the following:
57
-            // do_action('AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache__IDENTIFIER');
58
-            // where "IDENTIFIER" = the string that was set during construction
59
-            add_action(
60
-                "AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache__{$identifier}",
61
-                array($this, 'reset')
62
-            );
63
-        }
64
-        // to clear ALL caches, simply do the following:
65
-        // do_action('AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache');
66
-        add_action(
67
-            'AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache',
68
-            array($this, 'reset')
69
-        );
70
-    }
71
-
72
-
73
-    /**
74
-     * @return string
75
-     */
76
-    public function identifier()
77
-    {
78
-        return $this->identifier;
79
-    }
80
-
81
-
82
-    /**
83
-     * @param string $identifier
84
-     * @throws InvalidDataTypeException
85
-     */
86
-    private function setIdentifier($identifier)
87
-    {
88
-        if (! is_string($identifier)) {
89
-            throw new InvalidDataTypeException('$identifier', $identifier, 'string');
90
-        }
91
-        $this->identifier = $identifier;
92
-    }
93
-
94
-
95
-    /**
96
-     * @param FullyQualifiedName|string $fqcn
97
-     * @param mixed                     $object
98
-     * @return bool
99
-     * @throws InvalidArgumentException
100
-     */
101
-    public function share($fqcn, $object)
102
-    {
103
-        if ($object instanceof $fqcn) {
104
-            return $this->cache->add($object, md5($fqcn));
105
-        }
106
-        throw new InvalidArgumentException(
107
-            sprintf(
108
-                esc_html__(
109
-                    'The supplied class name "%1$s" must match the class of the supplied object.',
110
-                    'event_espresso'
111
-                ),
112
-                $fqcn
113
-            )
114
-        );
115
-    }
116
-
117
-
118
-    /**
119
-     * @param FullyQualifiedName|string $fqcn
120
-     * @param array                     $arguments
121
-     * @param bool                      $shared
122
-     * @param array                     $interfaces
123
-     * @return mixed
124
-     */
125
-    public function load($fqcn, $arguments = array(), $shared = true, array $interfaces = array())
126
-    {
127
-        $fqcn = ltrim($fqcn, '\\');
128
-        // caching can be turned off via the following code:
129
-        // add_filter('FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', '__return_true');
130
-        if (apply_filters(
131
-            'FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache',
132
-            false,
133
-            $this
134
-        )) {
135
-            // even though $shared might be true, caching could be bypassed for whatever reason,
136
-            // so we don't want the core loader to cache anything, therefore caching is turned off
137
-            return $this->loader->load($fqcn, $arguments, false);
138
-        }
139
-        $object_identifier = $this->object_identifier->getIdentifier($fqcn, $arguments);
140
-        if ($this->cache->has($object_identifier)) {
141
-            return $this->cache->get($object_identifier);
142
-        }
143
-        $object = $this->loader->load($fqcn, $arguments, $shared);
144
-        if ($object instanceof $fqcn) {
145
-            $this->cache->add($object, $object_identifier);
146
-        }
147
-        return $object;
148
-    }
149
-
150
-
151
-    /**
152
-     * empties cache and calls reset() on loader if method exists
153
-     */
154
-    public function reset()
155
-    {
156
-        $this->clearCache();
157
-        $this->loader->reset();
158
-    }
159
-
160
-
161
-    /**
162
-     * unsets and detaches ALL objects from the cache
163
-     *
164
-     * @since $VID:$
165
-     */
166
-    public function clearCache()
167
-    {
168
-        $this->cache->trashAndDetachAll();
169
-    }
20
+	/**
21
+	 * @var string $identifier
22
+	 */
23
+	protected $identifier;
24
+
25
+	/**
26
+	 * @var CollectionInterface $cache
27
+	 */
28
+	protected $cache;
29
+
30
+	/**
31
+	 * @var ObjectIdentifier
32
+	 */
33
+	private $object_identifier;
34
+
35
+
36
+	/**
37
+	 * CachingLoader constructor.
38
+	 *
39
+	 * @param LoaderDecoratorInterface $loader
40
+	 * @param CollectionInterface      $cache
41
+	 * @param ObjectIdentifier         $object_identifier
42
+	 * @param string                   $identifier
43
+	 * @throws InvalidDataTypeException
44
+	 */
45
+	public function __construct(
46
+		LoaderDecoratorInterface $loader,
47
+		CollectionInterface $cache,
48
+		ObjectIdentifier $object_identifier,
49
+		$identifier = ''
50
+	) {
51
+		parent::__construct($loader);
52
+		$this->cache       = $cache;
53
+		$this->object_identifier = $object_identifier;
54
+		$this->setIdentifier($identifier);
55
+		if ($this->identifier !== '') {
56
+			// to only clear this cache, and assuming an identifier has been set, simply do the following:
57
+			// do_action('AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache__IDENTIFIER');
58
+			// where "IDENTIFIER" = the string that was set during construction
59
+			add_action(
60
+				"AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache__{$identifier}",
61
+				array($this, 'reset')
62
+			);
63
+		}
64
+		// to clear ALL caches, simply do the following:
65
+		// do_action('AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache');
66
+		add_action(
67
+			'AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache',
68
+			array($this, 'reset')
69
+		);
70
+	}
71
+
72
+
73
+	/**
74
+	 * @return string
75
+	 */
76
+	public function identifier()
77
+	{
78
+		return $this->identifier;
79
+	}
80
+
81
+
82
+	/**
83
+	 * @param string $identifier
84
+	 * @throws InvalidDataTypeException
85
+	 */
86
+	private function setIdentifier($identifier)
87
+	{
88
+		if (! is_string($identifier)) {
89
+			throw new InvalidDataTypeException('$identifier', $identifier, 'string');
90
+		}
91
+		$this->identifier = $identifier;
92
+	}
93
+
94
+
95
+	/**
96
+	 * @param FullyQualifiedName|string $fqcn
97
+	 * @param mixed                     $object
98
+	 * @return bool
99
+	 * @throws InvalidArgumentException
100
+	 */
101
+	public function share($fqcn, $object)
102
+	{
103
+		if ($object instanceof $fqcn) {
104
+			return $this->cache->add($object, md5($fqcn));
105
+		}
106
+		throw new InvalidArgumentException(
107
+			sprintf(
108
+				esc_html__(
109
+					'The supplied class name "%1$s" must match the class of the supplied object.',
110
+					'event_espresso'
111
+				),
112
+				$fqcn
113
+			)
114
+		);
115
+	}
116
+
117
+
118
+	/**
119
+	 * @param FullyQualifiedName|string $fqcn
120
+	 * @param array                     $arguments
121
+	 * @param bool                      $shared
122
+	 * @param array                     $interfaces
123
+	 * @return mixed
124
+	 */
125
+	public function load($fqcn, $arguments = array(), $shared = true, array $interfaces = array())
126
+	{
127
+		$fqcn = ltrim($fqcn, '\\');
128
+		// caching can be turned off via the following code:
129
+		// add_filter('FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', '__return_true');
130
+		if (apply_filters(
131
+			'FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache',
132
+			false,
133
+			$this
134
+		)) {
135
+			// even though $shared might be true, caching could be bypassed for whatever reason,
136
+			// so we don't want the core loader to cache anything, therefore caching is turned off
137
+			return $this->loader->load($fqcn, $arguments, false);
138
+		}
139
+		$object_identifier = $this->object_identifier->getIdentifier($fqcn, $arguments);
140
+		if ($this->cache->has($object_identifier)) {
141
+			return $this->cache->get($object_identifier);
142
+		}
143
+		$object = $this->loader->load($fqcn, $arguments, $shared);
144
+		if ($object instanceof $fqcn) {
145
+			$this->cache->add($object, $object_identifier);
146
+		}
147
+		return $object;
148
+	}
149
+
150
+
151
+	/**
152
+	 * empties cache and calls reset() on loader if method exists
153
+	 */
154
+	public function reset()
155
+	{
156
+		$this->clearCache();
157
+		$this->loader->reset();
158
+	}
159
+
160
+
161
+	/**
162
+	 * unsets and detaches ALL objects from the cache
163
+	 *
164
+	 * @since $VID:$
165
+	 */
166
+	public function clearCache()
167
+	{
168
+		$this->cache->trashAndDetachAll();
169
+	}
170 170
 }
Please login to merge, or discard this patch.
core/services/loaders/LoaderFactory.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -80,47 +80,47 @@
 block discarded – undo
80 80
 class LoaderFactory
81 81
 {
82 82
 
83
-    /**
84
-     * @var LoaderInterface $loader ;
85
-     */
86
-    private static $loader;
83
+	/**
84
+	 * @var LoaderInterface $loader ;
85
+	 */
86
+	private static $loader;
87 87
 
88 88
 
89
-    /**
90
-     * @param EE_Registry|CoffeeShop   $generator   provided during very first instantiation in
91
-     *                                              BootstrapDependencyInjectionContainer::buildLoader()
92
-     *                                              otherwise can be left null
93
-     * @param ClassInterfaceCache|null $class_cache also provided during first instantiation
94
-     * @param ObjectIdentifier|null    $object_identifier
95
-     * @return LoaderInterface
96
-     * @throws InvalidArgumentException
97
-     * @throws InvalidDataTypeException
98
-     * @throws InvalidInterfaceException
99
-     */
100
-    public static function getLoader(
101
-        $generator = null,
102
-        ClassInterfaceCache $class_cache = null,
103
-        ObjectIdentifier $object_identifier = null
104
-    ) {
105
-        if (
106
-            ! LoaderFactory::$loader instanceof LoaderInterface
107
-            && ($generator instanceof EE_Registry || $generator instanceof CoffeeShop)
108
-            && $class_cache instanceof ClassInterfaceCache
109
-            && $object_identifier instanceof ObjectIdentifier
110
-        ) {
111
-            $core_loader = new CoreLoader($generator);
112
-            LoaderFactory::$loader = new Loader(
113
-                $core_loader,
114
-                new CachingLoader(
115
-                    $core_loader,
116
-                    new LooseCollection(''),
117
-                    $object_identifier
118
-                ),
119
-                $class_cache
120
-            );
121
-        }
122
-        return LoaderFactory::$loader;
123
-    }
89
+	/**
90
+	 * @param EE_Registry|CoffeeShop   $generator   provided during very first instantiation in
91
+	 *                                              BootstrapDependencyInjectionContainer::buildLoader()
92
+	 *                                              otherwise can be left null
93
+	 * @param ClassInterfaceCache|null $class_cache also provided during first instantiation
94
+	 * @param ObjectIdentifier|null    $object_identifier
95
+	 * @return LoaderInterface
96
+	 * @throws InvalidArgumentException
97
+	 * @throws InvalidDataTypeException
98
+	 * @throws InvalidInterfaceException
99
+	 */
100
+	public static function getLoader(
101
+		$generator = null,
102
+		ClassInterfaceCache $class_cache = null,
103
+		ObjectIdentifier $object_identifier = null
104
+	) {
105
+		if (
106
+			! LoaderFactory::$loader instanceof LoaderInterface
107
+			&& ($generator instanceof EE_Registry || $generator instanceof CoffeeShop)
108
+			&& $class_cache instanceof ClassInterfaceCache
109
+			&& $object_identifier instanceof ObjectIdentifier
110
+		) {
111
+			$core_loader = new CoreLoader($generator);
112
+			LoaderFactory::$loader = new Loader(
113
+				$core_loader,
114
+				new CachingLoader(
115
+					$core_loader,
116
+					new LooseCollection(''),
117
+					$object_identifier
118
+				),
119
+				$class_cache
120
+			);
121
+		}
122
+		return LoaderFactory::$loader;
123
+	}
124 124
 
125 125
 
126 126
 }
Please login to merge, or discard this patch.
core/domain/DomainFactory.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -28,63 +28,63 @@
 block discarded – undo
28 28
 class DomainFactory
29 29
 {
30 30
 
31
-    /**
32
-     * @param FullyQualifiedName $domain_fqcn   [required] Fully Qualified Class Name for the Domain class
33
-     * @param array $arguments                  [required] array of arguments to be passed to the Domain class
34
-     *                                          constructor. Must at least include the following two value objects:
35
-     *                                          array(
36
-     *                                              EventEspresso\core\domain\values\FilePath $plugin_file
37
-     *                                              EventEspresso\core\domain\values\Version $version
38
-     *                                          )
39
-     * @return mixed
40
-     * @throws DomainException
41
-     * @throws InvalidArgumentException
42
-     * @throws InvalidDataTypeException
43
-     * @throws InvalidInterfaceException
44
-     */
45
-    public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments)
46
-    {
47
-        if (! isset($arguments[0], $arguments[1])) {
48
-            throw new InvalidArgumentException(
49
-                esc_html__(
50
-                    'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class',
51
-                    'event_espresso'
52
-                )
53
-            );
54
-        }
55
-        $domain = LoaderFactory::getLoader()->getShared($domain_fqcn, $arguments);
56
-        if (! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) {
57
-            throw new DomainException(
58
-                sprintf(
59
-                    esc_html__(
60
-                        'The requested Domain class "%1$s" could not be loaded.',
61
-                        'event_espresso'
62
-                    ),
63
-                    $domain_fqcn
64
-                )
65
-            );
66
-        }
67
-        return $domain;
68
-    }
31
+	/**
32
+	 * @param FullyQualifiedName $domain_fqcn   [required] Fully Qualified Class Name for the Domain class
33
+	 * @param array $arguments                  [required] array of arguments to be passed to the Domain class
34
+	 *                                          constructor. Must at least include the following two value objects:
35
+	 *                                          array(
36
+	 *                                              EventEspresso\core\domain\values\FilePath $plugin_file
37
+	 *                                              EventEspresso\core\domain\values\Version $version
38
+	 *                                          )
39
+	 * @return mixed
40
+	 * @throws DomainException
41
+	 * @throws InvalidArgumentException
42
+	 * @throws InvalidDataTypeException
43
+	 * @throws InvalidInterfaceException
44
+	 */
45
+	public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments)
46
+	{
47
+		if (! isset($arguments[0], $arguments[1])) {
48
+			throw new InvalidArgumentException(
49
+				esc_html__(
50
+					'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class',
51
+					'event_espresso'
52
+				)
53
+			);
54
+		}
55
+		$domain = LoaderFactory::getLoader()->getShared($domain_fqcn, $arguments);
56
+		if (! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) {
57
+			throw new DomainException(
58
+				sprintf(
59
+					esc_html__(
60
+						'The requested Domain class "%1$s" could not be loaded.',
61
+						'event_espresso'
62
+					),
63
+					$domain_fqcn
64
+				)
65
+			);
66
+		}
67
+		return $domain;
68
+	}
69 69
 
70 70
 
71
-    /**
72
-     * @return Domain
73
-     * @throws DomainException
74
-     * @throws InvalidArgumentException
75
-     * @throws InvalidDataTypeException
76
-     * @throws InvalidFilePathException
77
-     * @throws InvalidInterfaceException
78
-     */
79
-    public static function getEventEspressoCoreDomain()
80
-    {
81
-        $domain = new Domain(
82
-            new FilePath(EVENT_ESPRESSO_MAIN_FILE),
83
-            Version::fromString(espresso_version())
84
-        );
85
-        LoaderFactory::getLoader()->share('EventEspresso\core\domain\Domain', $domain);
86
-        return $domain;
87
-    }
71
+	/**
72
+	 * @return Domain
73
+	 * @throws DomainException
74
+	 * @throws InvalidArgumentException
75
+	 * @throws InvalidDataTypeException
76
+	 * @throws InvalidFilePathException
77
+	 * @throws InvalidInterfaceException
78
+	 */
79
+	public static function getEventEspressoCoreDomain()
80
+	{
81
+		$domain = new Domain(
82
+			new FilePath(EVENT_ESPRESSO_MAIN_FILE),
83
+			Version::fromString(espresso_version())
84
+		);
85
+		LoaderFactory::getLoader()->share('EventEspresso\core\domain\Domain', $domain);
86
+		return $domain;
87
+	}
88 88
 }
89 89
 
90 90
 
Please login to merge, or discard this patch.
core/services/collections/Collection.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
      *
157 157
      * @access public
158 158
      * @param mixed $identifier
159
-     * @return mixed
159
+     * @return boolean
160 160
      */
161 161
     public function get($identifier)
162 162
     {
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
      * advances pointer to the provided object
279 279
      *
280 280
      * @access public
281
-     * @param $object
281
+     * @param \EventEspresso\core\libraries\form_sections\form_handlers\SequentialStepForm $object
282 282
      * @return boolean
283 283
      */
284 284
     public function setCurrentUsingObject($object)
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
      *
317 317
      * @see http://stackoverflow.com/a/8736013
318 318
      * @param $object
319
-     * @return boolean|int|string
319
+     * @return integer
320 320
      */
321 321
     public function indexOf($object)
322 322
     {
Please login to merge, or discard this patch.
Indentation   +383 added lines, -383 removed lines patch added patch discarded remove patch
@@ -19,387 +19,387 @@
 block discarded – undo
19 19
 {
20 20
 
21 21
 
22
-    /**
23
-     * an interface (or class) name to be used for restricting the type of objects added to the storage
24
-     * this should be set from within the child class constructor
25
-     *
26
-     * @type string $interface
27
-     */
28
-    protected $collection_interface;
29
-
30
-
31
-    /**
32
-     * Collection constructor
33
-     *
34
-     * @param string $collection_interface
35
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
36
-     */
37
-    public function __construct($collection_interface)
38
-    {
39
-        $this->setCollectionInterface($collection_interface);
40
-    }
41
-
42
-
43
-    /**
44
-     * setCollectionInterface
45
-     *
46
-     * @access protected
47
-     * @param  string $collection_interface
48
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
49
-     */
50
-    protected function setCollectionInterface($collection_interface)
51
-    {
52
-        if (! (interface_exists($collection_interface) || class_exists($collection_interface))) {
53
-            throw new InvalidInterfaceException($collection_interface);
54
-        }
55
-        $this->collection_interface = $collection_interface;
56
-    }
57
-
58
-
59
-    /**
60
-     * add
61
-     * attaches an object to the Collection
62
-     * and sets any supplied data associated with the current iterator entry
63
-     * by calling EE_Object_Collection::set_identifier()
64
-     *
65
-     * @access public
66
-     * @param        $object
67
-     * @param  mixed $identifier
68
-     * @return bool
69
-     * @throws \EventEspresso\core\exceptions\InvalidEntityException
70
-     */
71
-    public function add($object, $identifier = null)
72
-    {
73
-        if (! $object instanceof $this->collection_interface) {
74
-            throw new InvalidEntityException($object, $this->collection_interface);
75
-        }
76
-        $this->attach($object);
77
-        $this->setIdentifier($object, $identifier);
78
-        return $this->contains($object);
79
-    }
80
-
81
-
82
-    /**
83
-     * setIdentifier
84
-     * Sets the data associated with an object in the Collection
85
-     * if no $identifier is supplied, then the spl_object_hash() is used
86
-     *
87
-     * @access public
88
-     * @param        $object
89
-     * @param  mixed $identifier
90
-     * @return bool
91
-     */
92
-    public function setIdentifier($object, $identifier = null)
93
-    {
94
-        $identifier = ! empty($identifier) ? $identifier : spl_object_hash($object);
95
-        $this->rewind();
96
-        while ($this->valid()) {
97
-            if ($object === $this->current()) {
98
-                $this->setInfo($identifier);
99
-                $this->rewind();
100
-                return true;
101
-            }
102
-            $this->next();
103
-        }
104
-        return false;
105
-    }
106
-
107
-
108
-    /**
109
-     * get
110
-     * finds and returns an object in the Collection based on the identifier that was set using addObject()
111
-     * PLZ NOTE: the pointer is reset to the beginning of the collection before returning
112
-     *
113
-     * @access public
114
-     * @param mixed $identifier
115
-     * @return mixed
116
-     */
117
-    public function get($identifier)
118
-    {
119
-        $this->rewind();
120
-        while ($this->valid()) {
121
-            if ($identifier === $this->getInfo()) {
122
-                $object = $this->current();
123
-                $this->rewind();
124
-                return $object;
125
-            }
126
-            $this->next();
127
-        }
128
-        return null;
129
-    }
130
-
131
-
132
-    /**
133
-     * has
134
-     * returns TRUE or FALSE
135
-     * depending on whether the object is within the Collection
136
-     * based on the supplied $identifier
137
-     *
138
-     * @access public
139
-     * @param  mixed $identifier
140
-     * @return bool
141
-     */
142
-    public function has($identifier)
143
-    {
144
-        $this->rewind();
145
-        while ($this->valid()) {
146
-            if ($identifier === $this->getInfo()) {
147
-                $this->rewind();
148
-                return true;
149
-            }
150
-            $this->next();
151
-        }
152
-        return false;
153
-    }
154
-
155
-
156
-    /**
157
-     * hasObject
158
-     * returns TRUE or FALSE depending on whether the supplied object is within the Collection
159
-     *
160
-     * @access public
161
-     * @param $object
162
-     * @return bool
163
-     */
164
-    public function hasObject($object)
165
-    {
166
-        return $this->contains($object);
167
-    }
168
-
169
-
170
-    /**
171
-     * hasObjects
172
-     * returns true if there are objects within the Collection, and false if it is empty
173
-     *
174
-     * @access public
175
-     * @return bool
176
-     */
177
-    public function hasObjects()
178
-    {
179
-        return $this->count() !== 0;
180
-    }
181
-
182
-
183
-    /**
184
-     * isEmpty
185
-     * returns true if there are no objects within the Collection, and false if there are
186
-     *
187
-     * @access public
188
-     * @return bool
189
-     */
190
-    public function isEmpty()
191
-    {
192
-        return $this->count() === 0;
193
-    }
194
-
195
-
196
-    /**
197
-     * remove
198
-     * detaches an object from the Collection
199
-     *
200
-     * @access public
201
-     * @param $object
202
-     * @return bool
203
-     */
204
-    public function remove($object)
205
-    {
206
-        $this->detach($object);
207
-        return true;
208
-    }
209
-
210
-
211
-    /**
212
-     * setCurrent
213
-     * advances pointer to the object whose identifier matches that which was provided
214
-     *
215
-     * @access public
216
-     * @param mixed $identifier
217
-     * @return boolean
218
-     */
219
-    public function setCurrent($identifier)
220
-    {
221
-        $this->rewind();
222
-        while ($this->valid()) {
223
-            if ($identifier === $this->getInfo()) {
224
-                return true;
225
-            }
226
-            $this->next();
227
-        }
228
-        return false;
229
-    }
230
-
231
-
232
-    /**
233
-     * setCurrentUsingObject
234
-     * advances pointer to the provided object
235
-     *
236
-     * @access public
237
-     * @param $object
238
-     * @return boolean
239
-     */
240
-    public function setCurrentUsingObject($object)
241
-    {
242
-        $this->rewind();
243
-        while ($this->valid()) {
244
-            if ($this->current() === $object) {
245
-                return true;
246
-            }
247
-            $this->next();
248
-        }
249
-        return false;
250
-    }
251
-
252
-
253
-    /**
254
-     * Returns the object occupying the index before the current object,
255
-     * unless this is already the first object, in which case it just returns the first object
256
-     *
257
-     * @return mixed
258
-     */
259
-    public function previous()
260
-    {
261
-        $index = $this->indexOf($this->current());
262
-        if ($index === 0) {
263
-            return $this->current();
264
-        }
265
-        $index--;
266
-        return $this->objectAtIndex($index);
267
-    }
268
-
269
-
270
-    /**
271
-     * Returns the index of a given object, or false if not found
272
-     *
273
-     * @see http://stackoverflow.com/a/8736013
274
-     * @param $object
275
-     * @return boolean|int|string
276
-     */
277
-    public function indexOf($object)
278
-    {
279
-        if (! $this->contains($object)) {
280
-            return false;
281
-        }
282
-        foreach ($this as $index => $obj) {
283
-            if ($obj === $object) {
284
-                return $index;
285
-            }
286
-        }
287
-        return false;
288
-    }
289
-
290
-
291
-    /**
292
-     * Returns the object at the given index
293
-     *
294
-     * @see http://stackoverflow.com/a/8736013
295
-     * @param int $index
296
-     * @return mixed
297
-     */
298
-    public function objectAtIndex($index)
299
-    {
300
-        $iterator = new LimitIterator($this, $index, 1);
301
-        $iterator->rewind();
302
-        return $iterator->current();
303
-    }
304
-
305
-
306
-    /**
307
-     * Returns the sequence of objects as specified by the offset and length
308
-     *
309
-     * @see http://stackoverflow.com/a/8736013
310
-     * @param int $offset
311
-     * @param int $length
312
-     * @return array
313
-     */
314
-    public function slice($offset, $length)
315
-    {
316
-        $slice = array();
317
-        $iterator = new LimitIterator($this, $offset, $length);
318
-        foreach ($iterator as $object) {
319
-            $slice[] = $object;
320
-        }
321
-        return $slice;
322
-    }
323
-
324
-
325
-    /**
326
-     * Inserts an object (or an array of objects) at a certain point
327
-     *
328
-     * @see http://stackoverflow.com/a/8736013
329
-     * @param mixed $objects A single object or an array of objects
330
-     * @param int   $index
331
-     */
332
-    public function insertAt($objects, $index)
333
-    {
334
-        if (! is_array($objects)) {
335
-            $objects = array($objects);
336
-        }
337
-        // check to ensure that objects don't already exist in the collection
338
-        foreach ($objects as $key => $object) {
339
-            if ($this->contains($object)) {
340
-                unset($objects[ $key ]);
341
-            }
342
-        }
343
-        // do we have any objects left?
344
-        if (! $objects) {
345
-            return;
346
-        }
347
-        // detach any objects at or past this index
348
-        $remaining = array();
349
-        if ($index < $this->count()) {
350
-            $remaining = $this->slice($index, $this->count() - $index);
351
-            foreach ($remaining as $object) {
352
-                $this->detach($object);
353
-            }
354
-        }
355
-        // add the new objects we're splicing in
356
-        foreach ($objects as $object) {
357
-            $this->attach($object);
358
-        }
359
-        // attach the objects we previously detached
360
-        foreach ($remaining as $object) {
361
-            $this->attach($object);
362
-        }
363
-    }
364
-
365
-
366
-    /**
367
-     * Removes the object at the given index
368
-     *
369
-     * @see http://stackoverflow.com/a/8736013
370
-     * @param int $index
371
-     */
372
-    public function removeAt($index)
373
-    {
374
-        $this->detach($this->objectAtIndex($index));
375
-    }
376
-
377
-
378
-    /**
379
-     * detaches ALL objects from the Collection
380
-     */
381
-    public function detachAll()
382
-    {
383
-        $this->rewind();
384
-        while ($this->valid()) {
385
-            $object = $this->current();
386
-            $this->next();
387
-            $this->detach($object);
388
-        }
389
-    }
390
-
391
-
392
-    /**
393
-     * unsets and detaches ALL objects from the Collection
394
-     */
395
-    public function trashAndDetachAll()
396
-    {
397
-        $this->rewind();
398
-        while ($this->valid()) {
399
-            $object = $this->current();
400
-            $this->next();
401
-            $this->detach($object);
402
-            unset($object);
403
-        }
404
-    }
22
+	/**
23
+	 * an interface (or class) name to be used for restricting the type of objects added to the storage
24
+	 * this should be set from within the child class constructor
25
+	 *
26
+	 * @type string $interface
27
+	 */
28
+	protected $collection_interface;
29
+
30
+
31
+	/**
32
+	 * Collection constructor
33
+	 *
34
+	 * @param string $collection_interface
35
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
36
+	 */
37
+	public function __construct($collection_interface)
38
+	{
39
+		$this->setCollectionInterface($collection_interface);
40
+	}
41
+
42
+
43
+	/**
44
+	 * setCollectionInterface
45
+	 *
46
+	 * @access protected
47
+	 * @param  string $collection_interface
48
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
49
+	 */
50
+	protected function setCollectionInterface($collection_interface)
51
+	{
52
+		if (! (interface_exists($collection_interface) || class_exists($collection_interface))) {
53
+			throw new InvalidInterfaceException($collection_interface);
54
+		}
55
+		$this->collection_interface = $collection_interface;
56
+	}
57
+
58
+
59
+	/**
60
+	 * add
61
+	 * attaches an object to the Collection
62
+	 * and sets any supplied data associated with the current iterator entry
63
+	 * by calling EE_Object_Collection::set_identifier()
64
+	 *
65
+	 * @access public
66
+	 * @param        $object
67
+	 * @param  mixed $identifier
68
+	 * @return bool
69
+	 * @throws \EventEspresso\core\exceptions\InvalidEntityException
70
+	 */
71
+	public function add($object, $identifier = null)
72
+	{
73
+		if (! $object instanceof $this->collection_interface) {
74
+			throw new InvalidEntityException($object, $this->collection_interface);
75
+		}
76
+		$this->attach($object);
77
+		$this->setIdentifier($object, $identifier);
78
+		return $this->contains($object);
79
+	}
80
+
81
+
82
+	/**
83
+	 * setIdentifier
84
+	 * Sets the data associated with an object in the Collection
85
+	 * if no $identifier is supplied, then the spl_object_hash() is used
86
+	 *
87
+	 * @access public
88
+	 * @param        $object
89
+	 * @param  mixed $identifier
90
+	 * @return bool
91
+	 */
92
+	public function setIdentifier($object, $identifier = null)
93
+	{
94
+		$identifier = ! empty($identifier) ? $identifier : spl_object_hash($object);
95
+		$this->rewind();
96
+		while ($this->valid()) {
97
+			if ($object === $this->current()) {
98
+				$this->setInfo($identifier);
99
+				$this->rewind();
100
+				return true;
101
+			}
102
+			$this->next();
103
+		}
104
+		return false;
105
+	}
106
+
107
+
108
+	/**
109
+	 * get
110
+	 * finds and returns an object in the Collection based on the identifier that was set using addObject()
111
+	 * PLZ NOTE: the pointer is reset to the beginning of the collection before returning
112
+	 *
113
+	 * @access public
114
+	 * @param mixed $identifier
115
+	 * @return mixed
116
+	 */
117
+	public function get($identifier)
118
+	{
119
+		$this->rewind();
120
+		while ($this->valid()) {
121
+			if ($identifier === $this->getInfo()) {
122
+				$object = $this->current();
123
+				$this->rewind();
124
+				return $object;
125
+			}
126
+			$this->next();
127
+		}
128
+		return null;
129
+	}
130
+
131
+
132
+	/**
133
+	 * has
134
+	 * returns TRUE or FALSE
135
+	 * depending on whether the object is within the Collection
136
+	 * based on the supplied $identifier
137
+	 *
138
+	 * @access public
139
+	 * @param  mixed $identifier
140
+	 * @return bool
141
+	 */
142
+	public function has($identifier)
143
+	{
144
+		$this->rewind();
145
+		while ($this->valid()) {
146
+			if ($identifier === $this->getInfo()) {
147
+				$this->rewind();
148
+				return true;
149
+			}
150
+			$this->next();
151
+		}
152
+		return false;
153
+	}
154
+
155
+
156
+	/**
157
+	 * hasObject
158
+	 * returns TRUE or FALSE depending on whether the supplied object is within the Collection
159
+	 *
160
+	 * @access public
161
+	 * @param $object
162
+	 * @return bool
163
+	 */
164
+	public function hasObject($object)
165
+	{
166
+		return $this->contains($object);
167
+	}
168
+
169
+
170
+	/**
171
+	 * hasObjects
172
+	 * returns true if there are objects within the Collection, and false if it is empty
173
+	 *
174
+	 * @access public
175
+	 * @return bool
176
+	 */
177
+	public function hasObjects()
178
+	{
179
+		return $this->count() !== 0;
180
+	}
181
+
182
+
183
+	/**
184
+	 * isEmpty
185
+	 * returns true if there are no objects within the Collection, and false if there are
186
+	 *
187
+	 * @access public
188
+	 * @return bool
189
+	 */
190
+	public function isEmpty()
191
+	{
192
+		return $this->count() === 0;
193
+	}
194
+
195
+
196
+	/**
197
+	 * remove
198
+	 * detaches an object from the Collection
199
+	 *
200
+	 * @access public
201
+	 * @param $object
202
+	 * @return bool
203
+	 */
204
+	public function remove($object)
205
+	{
206
+		$this->detach($object);
207
+		return true;
208
+	}
209
+
210
+
211
+	/**
212
+	 * setCurrent
213
+	 * advances pointer to the object whose identifier matches that which was provided
214
+	 *
215
+	 * @access public
216
+	 * @param mixed $identifier
217
+	 * @return boolean
218
+	 */
219
+	public function setCurrent($identifier)
220
+	{
221
+		$this->rewind();
222
+		while ($this->valid()) {
223
+			if ($identifier === $this->getInfo()) {
224
+				return true;
225
+			}
226
+			$this->next();
227
+		}
228
+		return false;
229
+	}
230
+
231
+
232
+	/**
233
+	 * setCurrentUsingObject
234
+	 * advances pointer to the provided object
235
+	 *
236
+	 * @access public
237
+	 * @param $object
238
+	 * @return boolean
239
+	 */
240
+	public function setCurrentUsingObject($object)
241
+	{
242
+		$this->rewind();
243
+		while ($this->valid()) {
244
+			if ($this->current() === $object) {
245
+				return true;
246
+			}
247
+			$this->next();
248
+		}
249
+		return false;
250
+	}
251
+
252
+
253
+	/**
254
+	 * Returns the object occupying the index before the current object,
255
+	 * unless this is already the first object, in which case it just returns the first object
256
+	 *
257
+	 * @return mixed
258
+	 */
259
+	public function previous()
260
+	{
261
+		$index = $this->indexOf($this->current());
262
+		if ($index === 0) {
263
+			return $this->current();
264
+		}
265
+		$index--;
266
+		return $this->objectAtIndex($index);
267
+	}
268
+
269
+
270
+	/**
271
+	 * Returns the index of a given object, or false if not found
272
+	 *
273
+	 * @see http://stackoverflow.com/a/8736013
274
+	 * @param $object
275
+	 * @return boolean|int|string
276
+	 */
277
+	public function indexOf($object)
278
+	{
279
+		if (! $this->contains($object)) {
280
+			return false;
281
+		}
282
+		foreach ($this as $index => $obj) {
283
+			if ($obj === $object) {
284
+				return $index;
285
+			}
286
+		}
287
+		return false;
288
+	}
289
+
290
+
291
+	/**
292
+	 * Returns the object at the given index
293
+	 *
294
+	 * @see http://stackoverflow.com/a/8736013
295
+	 * @param int $index
296
+	 * @return mixed
297
+	 */
298
+	public function objectAtIndex($index)
299
+	{
300
+		$iterator = new LimitIterator($this, $index, 1);
301
+		$iterator->rewind();
302
+		return $iterator->current();
303
+	}
304
+
305
+
306
+	/**
307
+	 * Returns the sequence of objects as specified by the offset and length
308
+	 *
309
+	 * @see http://stackoverflow.com/a/8736013
310
+	 * @param int $offset
311
+	 * @param int $length
312
+	 * @return array
313
+	 */
314
+	public function slice($offset, $length)
315
+	{
316
+		$slice = array();
317
+		$iterator = new LimitIterator($this, $offset, $length);
318
+		foreach ($iterator as $object) {
319
+			$slice[] = $object;
320
+		}
321
+		return $slice;
322
+	}
323
+
324
+
325
+	/**
326
+	 * Inserts an object (or an array of objects) at a certain point
327
+	 *
328
+	 * @see http://stackoverflow.com/a/8736013
329
+	 * @param mixed $objects A single object or an array of objects
330
+	 * @param int   $index
331
+	 */
332
+	public function insertAt($objects, $index)
333
+	{
334
+		if (! is_array($objects)) {
335
+			$objects = array($objects);
336
+		}
337
+		// check to ensure that objects don't already exist in the collection
338
+		foreach ($objects as $key => $object) {
339
+			if ($this->contains($object)) {
340
+				unset($objects[ $key ]);
341
+			}
342
+		}
343
+		// do we have any objects left?
344
+		if (! $objects) {
345
+			return;
346
+		}
347
+		// detach any objects at or past this index
348
+		$remaining = array();
349
+		if ($index < $this->count()) {
350
+			$remaining = $this->slice($index, $this->count() - $index);
351
+			foreach ($remaining as $object) {
352
+				$this->detach($object);
353
+			}
354
+		}
355
+		// add the new objects we're splicing in
356
+		foreach ($objects as $object) {
357
+			$this->attach($object);
358
+		}
359
+		// attach the objects we previously detached
360
+		foreach ($remaining as $object) {
361
+			$this->attach($object);
362
+		}
363
+	}
364
+
365
+
366
+	/**
367
+	 * Removes the object at the given index
368
+	 *
369
+	 * @see http://stackoverflow.com/a/8736013
370
+	 * @param int $index
371
+	 */
372
+	public function removeAt($index)
373
+	{
374
+		$this->detach($this->objectAtIndex($index));
375
+	}
376
+
377
+
378
+	/**
379
+	 * detaches ALL objects from the Collection
380
+	 */
381
+	public function detachAll()
382
+	{
383
+		$this->rewind();
384
+		while ($this->valid()) {
385
+			$object = $this->current();
386
+			$this->next();
387
+			$this->detach($object);
388
+		}
389
+	}
390
+
391
+
392
+	/**
393
+	 * unsets and detaches ALL objects from the Collection
394
+	 */
395
+	public function trashAndDetachAll()
396
+	{
397
+		$this->rewind();
398
+		while ($this->valid()) {
399
+			$object = $this->current();
400
+			$this->next();
401
+			$this->detach($object);
402
+			unset($object);
403
+		}
404
+	}
405 405
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
      */
50 50
     protected function setCollectionInterface($collection_interface)
51 51
     {
52
-        if (! (interface_exists($collection_interface) || class_exists($collection_interface))) {
52
+        if ( ! (interface_exists($collection_interface) || class_exists($collection_interface))) {
53 53
             throw new InvalidInterfaceException($collection_interface);
54 54
         }
55 55
         $this->collection_interface = $collection_interface;
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      */
71 71
     public function add($object, $identifier = null)
72 72
     {
73
-        if (! $object instanceof $this->collection_interface) {
73
+        if ( ! $object instanceof $this->collection_interface) {
74 74
             throw new InvalidEntityException($object, $this->collection_interface);
75 75
         }
76 76
         $this->attach($object);
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
      */
277 277
     public function indexOf($object)
278 278
     {
279
-        if (! $this->contains($object)) {
279
+        if ( ! $this->contains($object)) {
280 280
             return false;
281 281
         }
282 282
         foreach ($this as $index => $obj) {
@@ -331,17 +331,17 @@  discard block
 block discarded – undo
331 331
      */
332 332
     public function insertAt($objects, $index)
333 333
     {
334
-        if (! is_array($objects)) {
334
+        if ( ! is_array($objects)) {
335 335
             $objects = array($objects);
336 336
         }
337 337
         // check to ensure that objects don't already exist in the collection
338 338
         foreach ($objects as $key => $object) {
339 339
             if ($this->contains($object)) {
340
-                unset($objects[ $key ]);
340
+                unset($objects[$key]);
341 341
             }
342 342
         }
343 343
         // do we have any objects left?
344
-        if (! $objects) {
344
+        if ( ! $objects) {
345 345
             return;
346 346
         }
347 347
         // detach any objects at or past this index
Please login to merge, or discard this patch.
core/domain/entities/GenericAddress.php 2 patches
Doc Comments   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,6 +37,8 @@  discard block
 block discarded – undo
37 37
      * @param \EE_State | string   $state
38 38
      * @param string               $zip
39 39
      * @param \EE_Country | string $country
40
+     * @param integer $state
41
+     * @param string $country
40 42
      * @return GenericAddress
41 43
      */
42 44
     public function __construct($address, $address2, $city, $state, $zip, $country)
@@ -130,7 +132,7 @@  discard block
 block discarded – undo
130 132
 
131 133
 
132 134
     /**
133
-     * @return \EE_State
135
+     * @return string
134 136
      */
135 137
     public function state_obj()
136 138
     {
@@ -183,7 +185,7 @@  discard block
 block discarded – undo
183 185
 
184 186
 
185 187
     /**
186
-     * @return \EE_Country
188
+     * @return string
187 189
      */
188 190
     public function country_obj()
189 191
     {
Please login to merge, or discard this patch.
Indentation   +201 added lines, -201 removed lines patch added patch discarded remove patch
@@ -12,205 +12,205 @@
 block discarded – undo
12 12
  */
13 13
 class GenericAddress implements \EEI_Address
14 14
 {
15
-    // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore
16
-    private $_address = '';
17
-
18
-    private $_address2 = '';
19
-
20
-    private $_city = '';
21
-
22
-    private $_state_ID = '';
23
-
24
-    private $_state_obj = '';
25
-
26
-    private $_zip = '';
27
-
28
-    private $_country_ID = '';
29
-
30
-    private $_country_obj = '';
31
-    // phpcs:enable
32
-
33
-    // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
34
-    /**
35
-     * @param string               $address
36
-     * @param string               $address2
37
-     * @param string               $city
38
-     * @param \EE_State | string   $state
39
-     * @param string               $zip
40
-     * @param \EE_Country | string $country
41
-     * @return GenericAddress
42
-     */
43
-    public function __construct($address, $address2, $city, $state, $zip, $country)
44
-    {
45
-        $this->_address = $address;
46
-        $this->_address2 = $address2;
47
-        $this->_city = $city;
48
-        if ($state instanceof \EE_State) {
49
-            $this->_state_obj = $state;
50
-        } else {
51
-            $this->_state_ID = $state;
52
-            $this->_state_obj = $this->_get_state_obj();
53
-        }
54
-        $this->_zip = $zip;
55
-        if ($country instanceof \EE_Country) {
56
-            $this->_country_obj = $country;
57
-        } else {
58
-            $this->_country_ID = $country;
59
-            $this->_country_obj = $this->_get_country_obj();
60
-        }
61
-    }
62
-
63
-
64
-    /**
65
-     * @return string
66
-     */
67
-    public function address()
68
-    {
69
-        return $this->_address;
70
-    }
71
-
72
-
73
-    /**
74
-     * @return string
75
-     */
76
-    public function address2()
77
-    {
78
-        return $this->_address2;
79
-    }
80
-
81
-
82
-    /**
83
-     * @return string
84
-     */
85
-    public function city()
86
-    {
87
-        return $this->_city;
88
-    }
89
-
90
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
91
-
92
-    /**
93
-     * @return \EE_State
94
-     */
95
-    private function _get_state_obj()
96
-    {
97
-        return $this->_state_obj instanceof \EE_State
98
-            ? $this->_state_obj
99
-            : \EE_Registry::instance()->load_model('State')->get_one_by_ID($this->_state_ID);
100
-    }
101
-
102
-
103
-    /**
104
-     * @return string
105
-     */
106
-    public function state_ID()
107
-    {
108
-        return $this->_state_ID;
109
-    }
110
-
111
-
112
-    /**
113
-     * @return string
114
-     */
115
-    public function state_abbrev()
116
-    {
117
-        return $this->state_obj() instanceof \EE_State
118
-            ? $this->state_obj()->abbrev()
119
-            : '';
120
-    }
121
-
122
-
123
-    /**
124
-     * @return string
125
-     */
126
-    public function state_name()
127
-    {
128
-        return $this->state_obj() instanceof \EE_State
129
-            ? $this->state_obj()->name()
130
-            : '';
131
-    }
132
-
133
-
134
-    /**
135
-     * @return \EE_State
136
-     */
137
-    public function state_obj()
138
-    {
139
-        return $this->_state_obj;
140
-    }
141
-
142
-
143
-    /**
144
-     * @return string
145
-     */
146
-    public function state()
147
-    {
148
-        if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
149
-            return $this->state_obj()->abbrev();
150
-        } else {
151
-            return $this->state_name();
152
-        }
153
-    }
154
-
155
-
156
-    /**
157
-     * @return \EE_Country
158
-     */
159
-    private function _get_country_obj()
160
-    {
161
-        return $this->_country_obj instanceof \EE_Country
162
-            ? $this->_country_obj
163
-            : \EE_Registry::instance()->load_model('Country')->get_one_by_ID($this->_country_ID);
164
-    }
165
-
166
-
167
-    /**
168
-     * @return string
169
-     */
170
-    public function country_ID()
171
-    {
172
-        return $this->_country_ID;
173
-    }
174
-
175
-
176
-    /**
177
-     * @return string
178
-     */
179
-    public function country_name()
180
-    {
181
-        return $this->country_obj() instanceof \EE_Country
182
-            ? $this->country_obj()->name()
183
-            : '';
184
-    }
185
-
186
-
187
-    /**
188
-     * @return \EE_Country
189
-     */
190
-    public function country_obj()
191
-    {
192
-        return $this->_country_obj;
193
-    }
194
-
195
-
196
-    /**
197
-     * @return string
198
-     */
199
-    public function country()
200
-    {
201
-        if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
202
-            return $this->country_ID();
203
-        } else {
204
-            return $this->country_name();
205
-        }
206
-    }
207
-
208
-
209
-    /**
210
-     * @return string
211
-     */
212
-    public function zip()
213
-    {
214
-        return $this->_zip;
215
-    }
15
+	// phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore
16
+	private $_address = '';
17
+
18
+	private $_address2 = '';
19
+
20
+	private $_city = '';
21
+
22
+	private $_state_ID = '';
23
+
24
+	private $_state_obj = '';
25
+
26
+	private $_zip = '';
27
+
28
+	private $_country_ID = '';
29
+
30
+	private $_country_obj = '';
31
+	// phpcs:enable
32
+
33
+	// phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
34
+	/**
35
+	 * @param string               $address
36
+	 * @param string               $address2
37
+	 * @param string               $city
38
+	 * @param \EE_State | string   $state
39
+	 * @param string               $zip
40
+	 * @param \EE_Country | string $country
41
+	 * @return GenericAddress
42
+	 */
43
+	public function __construct($address, $address2, $city, $state, $zip, $country)
44
+	{
45
+		$this->_address = $address;
46
+		$this->_address2 = $address2;
47
+		$this->_city = $city;
48
+		if ($state instanceof \EE_State) {
49
+			$this->_state_obj = $state;
50
+		} else {
51
+			$this->_state_ID = $state;
52
+			$this->_state_obj = $this->_get_state_obj();
53
+		}
54
+		$this->_zip = $zip;
55
+		if ($country instanceof \EE_Country) {
56
+			$this->_country_obj = $country;
57
+		} else {
58
+			$this->_country_ID = $country;
59
+			$this->_country_obj = $this->_get_country_obj();
60
+		}
61
+	}
62
+
63
+
64
+	/**
65
+	 * @return string
66
+	 */
67
+	public function address()
68
+	{
69
+		return $this->_address;
70
+	}
71
+
72
+
73
+	/**
74
+	 * @return string
75
+	 */
76
+	public function address2()
77
+	{
78
+		return $this->_address2;
79
+	}
80
+
81
+
82
+	/**
83
+	 * @return string
84
+	 */
85
+	public function city()
86
+	{
87
+		return $this->_city;
88
+	}
89
+
90
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
91
+
92
+	/**
93
+	 * @return \EE_State
94
+	 */
95
+	private function _get_state_obj()
96
+	{
97
+		return $this->_state_obj instanceof \EE_State
98
+			? $this->_state_obj
99
+			: \EE_Registry::instance()->load_model('State')->get_one_by_ID($this->_state_ID);
100
+	}
101
+
102
+
103
+	/**
104
+	 * @return string
105
+	 */
106
+	public function state_ID()
107
+	{
108
+		return $this->_state_ID;
109
+	}
110
+
111
+
112
+	/**
113
+	 * @return string
114
+	 */
115
+	public function state_abbrev()
116
+	{
117
+		return $this->state_obj() instanceof \EE_State
118
+			? $this->state_obj()->abbrev()
119
+			: '';
120
+	}
121
+
122
+
123
+	/**
124
+	 * @return string
125
+	 */
126
+	public function state_name()
127
+	{
128
+		return $this->state_obj() instanceof \EE_State
129
+			? $this->state_obj()->name()
130
+			: '';
131
+	}
132
+
133
+
134
+	/**
135
+	 * @return \EE_State
136
+	 */
137
+	public function state_obj()
138
+	{
139
+		return $this->_state_obj;
140
+	}
141
+
142
+
143
+	/**
144
+	 * @return string
145
+	 */
146
+	public function state()
147
+	{
148
+		if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
149
+			return $this->state_obj()->abbrev();
150
+		} else {
151
+			return $this->state_name();
152
+		}
153
+	}
154
+
155
+
156
+	/**
157
+	 * @return \EE_Country
158
+	 */
159
+	private function _get_country_obj()
160
+	{
161
+		return $this->_country_obj instanceof \EE_Country
162
+			? $this->_country_obj
163
+			: \EE_Registry::instance()->load_model('Country')->get_one_by_ID($this->_country_ID);
164
+	}
165
+
166
+
167
+	/**
168
+	 * @return string
169
+	 */
170
+	public function country_ID()
171
+	{
172
+		return $this->_country_ID;
173
+	}
174
+
175
+
176
+	/**
177
+	 * @return string
178
+	 */
179
+	public function country_name()
180
+	{
181
+		return $this->country_obj() instanceof \EE_Country
182
+			? $this->country_obj()->name()
183
+			: '';
184
+	}
185
+
186
+
187
+	/**
188
+	 * @return \EE_Country
189
+	 */
190
+	public function country_obj()
191
+	{
192
+		return $this->_country_obj;
193
+	}
194
+
195
+
196
+	/**
197
+	 * @return string
198
+	 */
199
+	public function country()
200
+	{
201
+		if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
202
+			return $this->country_ID();
203
+		} else {
204
+			return $this->country_name();
205
+		}
206
+	}
207
+
208
+
209
+	/**
210
+	 * @return string
211
+	 */
212
+	public function zip()
213
+	{
214
+		return $this->_zip;
215
+	}
216 216
 }
Please login to merge, or discard this patch.