Completed
Branch dependabot/composer/tijsverkoy... (491ea6)
by
unknown
32:00 queued 25:42
created
core/services/privacy/export/PersonalDataExporterManager.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
         // load all the privacy policy stuff
44 44
         // add post policy text
45 45
         foreach ($this->loadPrivateDataExporterCollection() as $exporter) {
46
-            $exporters[ get_class($exporter) ] = array(
46
+            $exporters[get_class($exporter)] = array(
47 47
                 'exporter_friendly_name' => $exporter->name(),
48 48
                 'callback'               => array($exporter, 'export'),
49 49
             );
Please login to merge, or discard this patch.
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -22,68 +22,68 @@
 block discarded – undo
22 22
  */
23 23
 class PersonalDataExporterManager
24 24
 {
25
-    public function __construct()
26
-    {
27
-        add_filter(
28
-            'wp_privacy_personal_data_exporters',
29
-            array($this, 'hookInExporters')
30
-        );
31
-    }
25
+	public function __construct()
26
+	{
27
+		add_filter(
28
+			'wp_privacy_personal_data_exporters',
29
+			array($this, 'hookInExporters')
30
+		);
31
+	}
32 32
 
33 33
 
34
-    /**
35
-     * Adds EE's exporters to the list of WP exporters
36
-     *
37
-     * @param array $exporters
38
-     * @return array
39
-     */
40
-    public function hookInExporters($exporters)
41
-    {
42
-        // load all the privacy policy stuff
43
-        // add post policy text
44
-        foreach ($this->loadPrivateDataExporterCollection() as $exporter) {
45
-            $exporters[ get_class($exporter) ] = array(
46
-                'exporter_friendly_name' => $exporter->name(),
47
-                'callback'               => array($exporter, 'export'),
48
-            );
49
-        }
50
-        return $exporters;
51
-    }
34
+	/**
35
+	 * Adds EE's exporters to the list of WP exporters
36
+	 *
37
+	 * @param array $exporters
38
+	 * @return array
39
+	 */
40
+	public function hookInExporters($exporters)
41
+	{
42
+		// load all the privacy policy stuff
43
+		// add post policy text
44
+		foreach ($this->loadPrivateDataExporterCollection() as $exporter) {
45
+			$exporters[ get_class($exporter) ] = array(
46
+				'exporter_friendly_name' => $exporter->name(),
47
+				'callback'               => array($exporter, 'export'),
48
+			);
49
+		}
50
+		return $exporters;
51
+	}
52 52
 
53 53
 
54
-    /**
55
-     * @return CollectionInterface|PersonalDataExporterInterface[]
56
-     * @throws InvalidIdentifierException
57
-     * @throws InvalidInterfaceException
58
-     * @throws InvalidFilePathException
59
-     * @throws InvalidEntityException
60
-     * @throws InvalidDataTypeException
61
-     * @throws InvalidClassException
62
-     */
63
-    protected function loadPrivateDataExporterCollection()
64
-    {
65
-        $loader = new CollectionLoader(
66
-            new CollectionDetails(
67
-                // collection name
68
-                'personal_data_exporters',
69
-                // collection interface
70
-                'EventEspresso\core\services\privacy\export\PersonalDataExporterInterface',
71
-                // FQCNs for classes to add (all classes within that namespace will be loaded)
72
-                apply_filters(
73
-                    'FHEE__EventEspresso_core_services_privacy_export_PersonalDataExporterManager__exporters',
74
-                    array('EventEspresso\core\domain\services\admin\privacy\export')
75
-                ),
76
-                // filepaths to classes to add
77
-                array(),
78
-                // file mask to use if parsing folder for files to add
79
-                '',
80
-                // what to use as identifier for collection entities
81
-                // using CLASS NAME prevents duplicates (works like a singleton)
82
-                CollectionDetails::ID_CLASS_NAME
83
-            )
84
-        );
85
-        return $loader->getCollection();
86
-    }
54
+	/**
55
+	 * @return CollectionInterface|PersonalDataExporterInterface[]
56
+	 * @throws InvalidIdentifierException
57
+	 * @throws InvalidInterfaceException
58
+	 * @throws InvalidFilePathException
59
+	 * @throws InvalidEntityException
60
+	 * @throws InvalidDataTypeException
61
+	 * @throws InvalidClassException
62
+	 */
63
+	protected function loadPrivateDataExporterCollection()
64
+	{
65
+		$loader = new CollectionLoader(
66
+			new CollectionDetails(
67
+				// collection name
68
+				'personal_data_exporters',
69
+				// collection interface
70
+				'EventEspresso\core\services\privacy\export\PersonalDataExporterInterface',
71
+				// FQCNs for classes to add (all classes within that namespace will be loaded)
72
+				apply_filters(
73
+					'FHEE__EventEspresso_core_services_privacy_export_PersonalDataExporterManager__exporters',
74
+					array('EventEspresso\core\domain\services\admin\privacy\export')
75
+				),
76
+				// filepaths to classes to add
77
+				array(),
78
+				// file mask to use if parsing folder for files to add
79
+				'',
80
+				// what to use as identifier for collection entities
81
+				// using CLASS NAME prevents duplicates (works like a singleton)
82
+				CollectionDetails::ID_CLASS_NAME
83
+			)
84
+		);
85
+		return $loader->getCollection();
86
+	}
87 87
 }
88 88
 
89 89
 // End of file PersonalDataExporterManager.php
Please login to merge, or discard this patch.
core/services/privacy/erasure/PersonalDataEraserManager.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
         // load all the privacy policy stuff
41 41
         // add post policy text
42 42
         foreach ($this->loadPrivateDataEraserCollection() as $eraser) {
43
-            $erasers[ get_class($eraser) ] = array(
43
+            $erasers[get_class($eraser)] = array(
44 44
                 'eraser_friendly_name' => $eraser->name(),
45 45
                 'callback'             => array($eraser, 'erase'),
46 46
             );
Please login to merge, or discard this patch.
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -22,65 +22,65 @@
 block discarded – undo
22 22
  */
23 23
 class PersonalDataEraserManager
24 24
 {
25
-    public function __construct()
26
-    {
27
-        add_filter(
28
-            'wp_privacy_personal_data_erasers',
29
-            array($this, 'hookInErasers')
30
-        );
31
-    }
25
+	public function __construct()
26
+	{
27
+		add_filter(
28
+			'wp_privacy_personal_data_erasers',
29
+			array($this, 'hookInErasers')
30
+		);
31
+	}
32 32
 
33 33
 
34
-    /**
35
-     * For all the registered `PrivateDataEraserInterface`s, add them as erasers
36
-     */
37
-    public function hookInErasers($erasers)
38
-    {
39
-        // load all the privacy policy stuff
40
-        // add post policy text
41
-        foreach ($this->loadPrivateDataEraserCollection() as $eraser) {
42
-            $erasers[ get_class($eraser) ] = array(
43
-                'eraser_friendly_name' => $eraser->name(),
44
-                'callback'             => array($eraser, 'erase'),
45
-            );
46
-        }
47
-        return $erasers;
48
-    }
34
+	/**
35
+	 * For all the registered `PrivateDataEraserInterface`s, add them as erasers
36
+	 */
37
+	public function hookInErasers($erasers)
38
+	{
39
+		// load all the privacy policy stuff
40
+		// add post policy text
41
+		foreach ($this->loadPrivateDataEraserCollection() as $eraser) {
42
+			$erasers[ get_class($eraser) ] = array(
43
+				'eraser_friendly_name' => $eraser->name(),
44
+				'callback'             => array($eraser, 'erase'),
45
+			);
46
+		}
47
+		return $erasers;
48
+	}
49 49
 
50 50
 
51
-    /**
52
-     * @return CollectionInterface|PersonalDataEraserInterface[]
53
-     * @throws InvalidIdentifierException
54
-     * @throws InvalidInterfaceException
55
-     * @throws InvalidFilePathException
56
-     * @throws InvalidEntityException
57
-     * @throws InvalidDataTypeException
58
-     * @throws InvalidClassException
59
-     */
60
-    protected function loadPrivateDataEraserCollection()
61
-    {
62
-        $loader = new CollectionLoader(
63
-            new CollectionDetails(
64
-                // collection name
65
-                'privacy_erasers',
66
-                // collection interface
67
-                'EventEspresso\core\services\privacy\erasure\PersonalDataEraserInterface',
68
-                // FQCNs for classes to add (all classes within that namespace will be loaded)
69
-                apply_filters(
70
-                    'FHEE__EventEspresso_core_services_privacy_erasure_PersonalDataEraserManager__erasers',
71
-                    array('EventEspresso\core\domain\services\admin\privacy\erasure')
72
-                ),
73
-                // filepaths to classes to add
74
-                array(),
75
-                // file mask to use if parsing folder for files to add
76
-                '',
77
-                // what to use as identifier for collection entities
78
-                // using CLASS NAME prevents duplicates (works like a singleton)
79
-                CollectionDetails::ID_CLASS_NAME
80
-            )
81
-        );
82
-        return $loader->getCollection();
83
-    }
51
+	/**
52
+	 * @return CollectionInterface|PersonalDataEraserInterface[]
53
+	 * @throws InvalidIdentifierException
54
+	 * @throws InvalidInterfaceException
55
+	 * @throws InvalidFilePathException
56
+	 * @throws InvalidEntityException
57
+	 * @throws InvalidDataTypeException
58
+	 * @throws InvalidClassException
59
+	 */
60
+	protected function loadPrivateDataEraserCollection()
61
+	{
62
+		$loader = new CollectionLoader(
63
+			new CollectionDetails(
64
+				// collection name
65
+				'privacy_erasers',
66
+				// collection interface
67
+				'EventEspresso\core\services\privacy\erasure\PersonalDataEraserInterface',
68
+				// FQCNs for classes to add (all classes within that namespace will be loaded)
69
+				apply_filters(
70
+					'FHEE__EventEspresso_core_services_privacy_erasure_PersonalDataEraserManager__erasers',
71
+					array('EventEspresso\core\domain\services\admin\privacy\erasure')
72
+				),
73
+				// filepaths to classes to add
74
+				array(),
75
+				// file mask to use if parsing folder for files to add
76
+				'',
77
+				// what to use as identifier for collection entities
78
+				// using CLASS NAME prevents duplicates (works like a singleton)
79
+				CollectionDetails::ID_CLASS_NAME
80
+			)
81
+		);
82
+		return $loader->getCollection();
83
+	}
84 84
 }
85 85
 // End of file PersonalDataEraserManager.php
86 86
 // Location: EventEspresso\core\domain\services\admin/PersonalDataEraserManager.php
Please login to merge, or discard this patch.
core/services/assets/AssetCollection.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
             /** @var Asset $asset */
76 76
             $asset = $this->current();
77 77
             if ($asset->type() === $type) {
78
-                $files[ $asset->handle() ] = $asset;
78
+                $files[$asset->handle()] = $asset;
79 79
             }
80 80
             $this->next();
81 81
         }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
             /** @var JavascriptAsset $asset */
97 97
             $asset = $this->current();
98 98
             if ($asset->type() === Asset::TYPE_JS && $asset->hasInlineData()) {
99
-                $files[ $asset->handle() ] = $asset;
99
+                $files[$asset->handle()] = $asset;
100 100
             }
101 101
             $this->next();
102 102
         }
Please login to merge, or discard this patch.
Indentation   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -21,192 +21,192 @@
 block discarded – undo
21 21
 {
22 22
 
23 23
 
24
-    /**
25
-     * AssetCollection constructor
26
-     *
27
-     * @throws InvalidInterfaceException
28
-     */
29
-    public function __construct()
30
-    {
31
-        parent::__construct('EventEspresso\core\domain\values\assets\Asset');
32
-    }
33
-
34
-
35
-    /**
36
-     * @return StylesheetAsset[]
37
-     * @since 4.9.62.p
38
-     */
39
-    public function getStylesheetAssets()
40
-    {
41
-        return $this->getAssetsOfType(Asset::TYPE_CSS);
42
-    }
43
-
44
-
45
-    /**
46
-     * @return JavascriptAsset[]
47
-     * @since 4.9.62.p
48
-     */
49
-    public function getJavascriptAssets()
50
-    {
51
-        return $this->getAssetsOfType(Asset::TYPE_JS);
52
-    }
53
-
54
-
55
-    /**
56
-     * @return ManifestFile[]
57
-     * @since 4.9.62.p
58
-     */
59
-    public function getManifestFiles()
60
-    {
61
-        return $this->getAssetsOfType(Asset::TYPE_MANIFEST);
62
-    }
63
-
64
-
65
-    /**
66
-     * @param $type
67
-     * @return JavascriptAsset[]|StylesheetAsset[]|ManifestFile[]
68
-     * @since 4.9.62.p
69
-     */
70
-    protected function getAssetsOfType($type)
71
-    {
72
-        $files = array();
73
-        $this->rewind();
74
-        while ($this->valid()) {
75
-            /** @var Asset $asset */
76
-            $asset = $this->current();
77
-            if ($asset->type() === $type) {
78
-                $files[ $asset->handle() ] = $asset;
79
-            }
80
-            $this->next();
81
-        }
82
-        $this->rewind();
83
-        return $files;
84
-    }
85
-
86
-
87
-    /**
88
-     * @return JavascriptAsset[]
89
-     * @since 4.9.62.p
90
-     */
91
-    public function getJavascriptAssetsWithData()
92
-    {
93
-        $files = array();
94
-        $this->rewind();
95
-        while ($this->valid()) {
96
-            /** @var JavascriptAsset $asset */
97
-            $asset = $this->current();
98
-            if ($asset->type() === Asset::TYPE_JS && $asset->hasInlineData()) {
99
-                $files[ $asset->handle() ] = $asset;
100
-            }
101
-            $this->next();
102
-        }
103
-        $this->rewind();
104
-        return $files;
105
-    }
106
-
107
-
108
-    /**
109
-     * returns TRUE or FALSE
110
-     * depending on whether the object is within the Collection
111
-     * based on the supplied $identifier and type
112
-     *
113
-     * @param  mixed $identifier
114
-     * @param string $type
115
-     * @return bool
116
-     * @since 4.9.63.p
117
-     */
118
-    public function hasAssetOfType($identifier, $type = Asset::TYPE_JS)
119
-    {
120
-        $this->rewind();
121
-        while ($this->valid()) {
122
-            if ($this->getInfo() === $identifier && $this->current()->type() === $type) {
123
-                $this->rewind();
124
-                return true;
125
-            }
126
-            $this->next();
127
-        }
128
-        return false;
129
-    }
130
-
131
-
132
-    /**
133
-     * returns TRUE or FALSE
134
-     * depending on whether the Javascript Asset is within the Collection
135
-     * based on the supplied $identifier
136
-     *
137
-     * @param  mixed $identifier
138
-     * @return bool
139
-     * @since 4.9.63.p
140
-     */
141
-    public function hasJavascriptAsset($identifier)
142
-    {
143
-        return $this->hasAssetOfType($identifier, Asset::TYPE_JS);
144
-    }
145
-
146
-
147
-    /**
148
-     * returns TRUE or FALSE
149
-     * depending on whether the Stylesheet Asset is within the Collection
150
-     * based on the supplied $identifier
151
-     *
152
-     * @param  mixed $identifier
153
-     * @return bool
154
-     * @since 4.9.63.p
155
-     */
156
-    public function hasStylesheetAsset($identifier)
157
-    {
158
-        return $this->hasAssetOfType($identifier, Asset::TYPE_CSS);
159
-    }
160
-
161
-    /**
162
-     * returns the object from the Collection
163
-     * based on the supplied $identifier and type
164
-     *
165
-     * @param  mixed $identifier
166
-     * @param string $type
167
-     * @return JavascriptAsset|StylesheetAsset
168
-     * @since 4.9.63.p
169
-     */
170
-    public function getAssetOfType($identifier, $type = Asset::TYPE_JS)
171
-    {
172
-        $this->rewind();
173
-        while ($this->valid()) {
174
-            if ($this->getInfo() === $identifier && $this->current()->type() === $type) {
175
-                /** @var JavascriptAsset|StylesheetAsset $object */
176
-                $object = $this->current();
177
-                $this->rewind();
178
-                return $object;
179
-            }
180
-            $this->next();
181
-        }
182
-        return null;
183
-    }
184
-
185
-
186
-    /**
187
-     * returns the Stylesheet Asset from the Collection
188
-     * based on the supplied $identifier
189
-     *
190
-     * @param  mixed $identifier
191
-     * @return StylesheetAsset
192
-     * @since 4.9.63.p
193
-     */
194
-    public function getStylesheetAsset($identifier)
195
-    {
196
-        return $this->getAssetOfType($identifier, Asset::TYPE_CSS);
197
-    }
198
-
199
-
200
-    /**
201
-     * returns the Javascript Asset from the Collection
202
-     * based on the supplied $identifier
203
-     *
204
-     * @param  mixed $identifier
205
-     * @return JavascriptAsset
206
-     * @since 4.9.63.p
207
-     */
208
-    public function getJavascriptAsset($identifier)
209
-    {
210
-        return $this->getAssetOfType($identifier, Asset::TYPE_JS);
211
-    }
24
+	/**
25
+	 * AssetCollection constructor
26
+	 *
27
+	 * @throws InvalidInterfaceException
28
+	 */
29
+	public function __construct()
30
+	{
31
+		parent::__construct('EventEspresso\core\domain\values\assets\Asset');
32
+	}
33
+
34
+
35
+	/**
36
+	 * @return StylesheetAsset[]
37
+	 * @since 4.9.62.p
38
+	 */
39
+	public function getStylesheetAssets()
40
+	{
41
+		return $this->getAssetsOfType(Asset::TYPE_CSS);
42
+	}
43
+
44
+
45
+	/**
46
+	 * @return JavascriptAsset[]
47
+	 * @since 4.9.62.p
48
+	 */
49
+	public function getJavascriptAssets()
50
+	{
51
+		return $this->getAssetsOfType(Asset::TYPE_JS);
52
+	}
53
+
54
+
55
+	/**
56
+	 * @return ManifestFile[]
57
+	 * @since 4.9.62.p
58
+	 */
59
+	public function getManifestFiles()
60
+	{
61
+		return $this->getAssetsOfType(Asset::TYPE_MANIFEST);
62
+	}
63
+
64
+
65
+	/**
66
+	 * @param $type
67
+	 * @return JavascriptAsset[]|StylesheetAsset[]|ManifestFile[]
68
+	 * @since 4.9.62.p
69
+	 */
70
+	protected function getAssetsOfType($type)
71
+	{
72
+		$files = array();
73
+		$this->rewind();
74
+		while ($this->valid()) {
75
+			/** @var Asset $asset */
76
+			$asset = $this->current();
77
+			if ($asset->type() === $type) {
78
+				$files[ $asset->handle() ] = $asset;
79
+			}
80
+			$this->next();
81
+		}
82
+		$this->rewind();
83
+		return $files;
84
+	}
85
+
86
+
87
+	/**
88
+	 * @return JavascriptAsset[]
89
+	 * @since 4.9.62.p
90
+	 */
91
+	public function getJavascriptAssetsWithData()
92
+	{
93
+		$files = array();
94
+		$this->rewind();
95
+		while ($this->valid()) {
96
+			/** @var JavascriptAsset $asset */
97
+			$asset = $this->current();
98
+			if ($asset->type() === Asset::TYPE_JS && $asset->hasInlineData()) {
99
+				$files[ $asset->handle() ] = $asset;
100
+			}
101
+			$this->next();
102
+		}
103
+		$this->rewind();
104
+		return $files;
105
+	}
106
+
107
+
108
+	/**
109
+	 * returns TRUE or FALSE
110
+	 * depending on whether the object is within the Collection
111
+	 * based on the supplied $identifier and type
112
+	 *
113
+	 * @param  mixed $identifier
114
+	 * @param string $type
115
+	 * @return bool
116
+	 * @since 4.9.63.p
117
+	 */
118
+	public function hasAssetOfType($identifier, $type = Asset::TYPE_JS)
119
+	{
120
+		$this->rewind();
121
+		while ($this->valid()) {
122
+			if ($this->getInfo() === $identifier && $this->current()->type() === $type) {
123
+				$this->rewind();
124
+				return true;
125
+			}
126
+			$this->next();
127
+		}
128
+		return false;
129
+	}
130
+
131
+
132
+	/**
133
+	 * returns TRUE or FALSE
134
+	 * depending on whether the Javascript Asset is within the Collection
135
+	 * based on the supplied $identifier
136
+	 *
137
+	 * @param  mixed $identifier
138
+	 * @return bool
139
+	 * @since 4.9.63.p
140
+	 */
141
+	public function hasJavascriptAsset($identifier)
142
+	{
143
+		return $this->hasAssetOfType($identifier, Asset::TYPE_JS);
144
+	}
145
+
146
+
147
+	/**
148
+	 * returns TRUE or FALSE
149
+	 * depending on whether the Stylesheet Asset is within the Collection
150
+	 * based on the supplied $identifier
151
+	 *
152
+	 * @param  mixed $identifier
153
+	 * @return bool
154
+	 * @since 4.9.63.p
155
+	 */
156
+	public function hasStylesheetAsset($identifier)
157
+	{
158
+		return $this->hasAssetOfType($identifier, Asset::TYPE_CSS);
159
+	}
160
+
161
+	/**
162
+	 * returns the object from the Collection
163
+	 * based on the supplied $identifier and type
164
+	 *
165
+	 * @param  mixed $identifier
166
+	 * @param string $type
167
+	 * @return JavascriptAsset|StylesheetAsset
168
+	 * @since 4.9.63.p
169
+	 */
170
+	public function getAssetOfType($identifier, $type = Asset::TYPE_JS)
171
+	{
172
+		$this->rewind();
173
+		while ($this->valid()) {
174
+			if ($this->getInfo() === $identifier && $this->current()->type() === $type) {
175
+				/** @var JavascriptAsset|StylesheetAsset $object */
176
+				$object = $this->current();
177
+				$this->rewind();
178
+				return $object;
179
+			}
180
+			$this->next();
181
+		}
182
+		return null;
183
+	}
184
+
185
+
186
+	/**
187
+	 * returns the Stylesheet Asset from the Collection
188
+	 * based on the supplied $identifier
189
+	 *
190
+	 * @param  mixed $identifier
191
+	 * @return StylesheetAsset
192
+	 * @since 4.9.63.p
193
+	 */
194
+	public function getStylesheetAsset($identifier)
195
+	{
196
+		return $this->getAssetOfType($identifier, Asset::TYPE_CSS);
197
+	}
198
+
199
+
200
+	/**
201
+	 * returns the Javascript Asset from the Collection
202
+	 * based on the supplied $identifier
203
+	 *
204
+	 * @param  mixed $identifier
205
+	 * @return JavascriptAsset
206
+	 * @since 4.9.63.p
207
+	 */
208
+	public function getJavascriptAsset($identifier)
209
+	{
210
+		return $this->getAssetOfType($identifier, Asset::TYPE_JS);
211
+	}
212 212
 }
Please login to merge, or discard this patch.
core/services/collections/Collection.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      */
67 67
     protected function setCollectionInterface($collection_interface)
68 68
     {
69
-        if (! (interface_exists($collection_interface) || class_exists($collection_interface))) {
69
+        if ( ! (interface_exists($collection_interface) || class_exists($collection_interface))) {
70 70
             throw new InvalidInterfaceException($collection_interface);
71 71
         }
72 72
         $this->collection_interface = $collection_interface;
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
     protected function setCollectionIdentifier()
112 112
     {
113 113
         // hash a few collection details
114
-        $identifier = md5(spl_object_hash($this) . $this->collection_interface . time());
114
+        $identifier = md5(spl_object_hash($this).$this->collection_interface.time());
115 115
         // grab a few characters from the start, middle, and end of the hash
116 116
         $id = array();
117 117
         for ($x = 0; $x < 19; $x += 9) {
118 118
             $id[] = substr($identifier, $x, 3);
119 119
         }
120
-        $this->collection_identifier = $this->collection_name . '-' . strtoupper(implode('-', $id));
120
+        $this->collection_identifier = $this->collection_name.'-'.strtoupper(implode('-', $id));
121 121
     }
122 122
 
123 123
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
      */
136 136
     public function add($object, $identifier = null)
137 137
     {
138
-        if (! $object instanceof $this->collection_interface) {
138
+        if ( ! $object instanceof $this->collection_interface) {
139 139
             throw new InvalidEntityException($object, $this->collection_interface);
140 140
         }
141 141
         if ($this->contains($object)) {
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
      */
352 352
     public function indexOf($object)
353 353
     {
354
-        if (! $this->contains($object)) {
354
+        if ( ! $this->contains($object)) {
355 355
             return false;
356 356
         }
357 357
         foreach ($this as $index => $obj) {
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
             $remaining_objects = $this->slice($index, $this->count() - $index);
421 421
             foreach ($remaining_objects as $key => $remaining_object) {
422 422
                 // we need to grab the identifiers for each object and use them as keys
423
-                $remaining_objects[ $remaining_object->getInfo() ] = $remaining_object;
423
+                $remaining_objects[$remaining_object->getInfo()] = $remaining_object;
424 424
                 // and then remove the object from the current tracking array
425
-                unset($remaining_objects[ $key ]);
425
+                unset($remaining_objects[$key]);
426 426
                 // and then remove it from the Collection
427 427
                 $this->detach($remaining_object);
428 428
             }
@@ -446,17 +446,17 @@  discard block
 block discarded – undo
446 446
      */
447 447
     public function insertAt($objects, $index)
448 448
     {
449
-        if (! is_array($objects)) {
449
+        if ( ! is_array($objects)) {
450 450
             $objects = array($objects);
451 451
         }
452 452
         // check to ensure that objects don't already exist in the collection
453 453
         foreach ($objects as $key => $object) {
454 454
             if ($this->contains($object)) {
455
-                unset($objects[ $key ]);
455
+                unset($objects[$key]);
456 456
             }
457 457
         }
458 458
         // do we have any objects left?
459
-        if (! $objects) {
459
+        if ( ! $objects) {
460 460
             return;
461 461
         }
462 462
         // detach any objects at or past this index
Please login to merge, or discard this patch.
Indentation   +510 added lines, -510 removed lines patch added patch discarded remove patch
@@ -18,514 +18,514 @@
 block discarded – undo
18 18
  */
19 19
 class Collection extends SplObjectStorage implements CollectionInterface
20 20
 {
21
-    /**
22
-     * a unique string for identifying this collection
23
-     *
24
-     * @type string $collection_identifier
25
-     */
26
-    protected $collection_identifier;
27
-
28
-
29
-    /**
30
-     * an interface (or class) name to be used for restricting the type of objects added to the storage
31
-     * this should be set from within the child class constructor
32
-     *
33
-     * @type string $interface
34
-     */
35
-    protected $collection_interface;
36
-
37
-    /**
38
-     * a short dash separated string describing the contents of this collection
39
-     * used as the base for the $collection_identifier
40
-     * defaults to the class short name if not set
41
-     *
42
-     * @type string $collection_identifier
43
-     */
44
-    protected $collection_name;
45
-
46
-
47
-    /**
48
-     * Collection constructor
49
-     *
50
-     * @param string $collection_interface
51
-     * @param string $collection_name
52
-     * @throws InvalidInterfaceException
53
-     */
54
-    public function __construct($collection_interface, $collection_name = '')
55
-    {
56
-        $this->setCollectionInterface($collection_interface);
57
-        $this->setCollectionName($collection_name);
58
-        $this->setCollectionIdentifier();
59
-    }
60
-
61
-
62
-    /**
63
-     * @return string
64
-     * @since 4.10.33.p
65
-     */
66
-    public function collectionInterface(): string
67
-    {
68
-        return $this->collection_interface;
69
-    }
70
-
71
-
72
-    /**
73
-     * setCollectionInterface
74
-     *
75
-     * @param  string $collection_interface
76
-     * @throws InvalidInterfaceException
77
-     */
78
-    protected function setCollectionInterface($collection_interface)
79
-    {
80
-        if (! (interface_exists($collection_interface) || class_exists($collection_interface))) {
81
-            throw new InvalidInterfaceException($collection_interface);
82
-        }
83
-        $this->collection_interface = $collection_interface;
84
-    }
85
-
86
-
87
-    /**
88
-     * @return string
89
-     */
90
-    public function collectionName()
91
-    {
92
-        return $this->collection_name;
93
-    }
94
-
95
-
96
-    /**
97
-     * @param string $collection_name
98
-     */
99
-    protected function setCollectionName($collection_name)
100
-    {
101
-        $this->collection_name = ! empty($collection_name)
102
-            ? sanitize_key($collection_name)
103
-            : basename(str_replace('\\', '/', get_class($this)));
104
-    }
105
-
106
-
107
-    /**
108
-     * @return string
109
-     */
110
-    public function collectionIdentifier()
111
-    {
112
-        return $this->collection_identifier;
113
-    }
114
-
115
-
116
-    /**
117
-     * creates a very readable unique 9 character identifier like:  CF2-532-DAC
118
-     * and appends it to the non-qualified class name, ex: ThingCollection-CF2-532-DAC
119
-     *
120
-     * @return void
121
-     */
122
-    protected function setCollectionIdentifier()
123
-    {
124
-        // hash a few collection details
125
-        $identifier = md5(spl_object_hash($this) . $this->collection_interface . time());
126
-        // grab a few characters from the start, middle, and end of the hash
127
-        $id = array();
128
-        for ($x = 0; $x < 19; $x += 9) {
129
-            $id[] = substr($identifier, $x, 3);
130
-        }
131
-        $this->collection_identifier = $this->collection_name . '-' . strtoupper(implode('-', $id));
132
-    }
133
-
134
-
135
-    /**
136
-     * add
137
-     * attaches an object to the Collection
138
-     * and sets any supplied data associated with the current iterator entry
139
-     * by calling EE_Object_Collection::set_identifier()
140
-     *
141
-     * @param        $object
142
-     * @param  mixed $identifier
143
-     * @return bool
144
-     * @throws InvalidEntityException
145
-     * @throws DuplicateCollectionIdentifierException
146
-     */
147
-    public function add($object, $identifier = null)
148
-    {
149
-        if (! $object instanceof $this->collection_interface) {
150
-            throw new InvalidEntityException($object, $this->collection_interface);
151
-        }
152
-        if ($this->contains($object)) {
153
-            throw new DuplicateCollectionIdentifierException($identifier);
154
-        }
155
-        $this->attach($object);
156
-        $this->setIdentifier($object, $identifier);
157
-        return $this->contains($object);
158
-    }
159
-
160
-
161
-    /**
162
-     * getIdentifier
163
-     * if no $identifier is supplied, then the spl_object_hash() is used
164
-     *
165
-     * @param        $object
166
-     * @param  mixed $identifier
167
-     * @return string
168
-     */
169
-    public function getIdentifier($object, $identifier = null)
170
-    {
171
-        return ! empty($identifier)
172
-            ? $identifier
173
-            : spl_object_hash($object);
174
-    }
175
-
176
-
177
-    /**
178
-     * setIdentifier
179
-     * Sets the data associated with an object in the Collection
180
-     * if no $identifier is supplied, then the spl_object_hash() is used
181
-     *
182
-     * @param        $object
183
-     * @param  mixed $identifier
184
-     * @return bool
185
-     */
186
-    public function setIdentifier($object, $identifier = null)
187
-    {
188
-        $identifier = $this->getIdentifier($object, $identifier);
189
-        $this->rewind();
190
-        while ($this->valid()) {
191
-            if ($object === $this->current()) {
192
-                $this->setInfo($identifier);
193
-                $this->rewind();
194
-                return true;
195
-            }
196
-            $this->next();
197
-        }
198
-        return false;
199
-    }
200
-
201
-
202
-    /**
203
-     * get
204
-     * finds and returns an object in the Collection based on the identifier that was set using addObject()
205
-     * PLZ NOTE: the pointer is reset to the beginning of the collection before returning
206
-     *
207
-     * @param mixed $identifier
208
-     * @return mixed
209
-     */
210
-    public function get($identifier)
211
-    {
212
-        $this->rewind();
213
-        while ($this->valid()) {
214
-            if ($identifier === $this->getInfo()) {
215
-                $object = $this->current();
216
-                $this->rewind();
217
-                return $object;
218
-            }
219
-            $this->next();
220
-        }
221
-        return null;
222
-    }
223
-
224
-
225
-    /**
226
-     * has
227
-     * returns TRUE or FALSE
228
-     * depending on whether the object is within the Collection
229
-     * based on the supplied $identifier
230
-     *
231
-     * @param  mixed $identifier
232
-     * @return bool
233
-     */
234
-    public function has($identifier)
235
-    {
236
-        $this->rewind();
237
-        while ($this->valid()) {
238
-            if ($identifier === $this->getInfo()) {
239
-                $this->rewind();
240
-                return true;
241
-            }
242
-            $this->next();
243
-        }
244
-        return false;
245
-    }
246
-
247
-
248
-    /**
249
-     * hasObject
250
-     * returns TRUE or FALSE depending on whether the supplied object is within the Collection
251
-     *
252
-     * @param $object
253
-     * @return bool
254
-     */
255
-    public function hasObject($object)
256
-    {
257
-        return $this->contains($object);
258
-    }
259
-
260
-
261
-    /**
262
-     * hasObjects
263
-     * returns true if there are objects within the Collection, and false if it is empty
264
-     *
265
-     * @return bool
266
-     */
267
-    public function hasObjects()
268
-    {
269
-        return $this->count() !== 0;
270
-    }
271
-
272
-
273
-    /**
274
-     * isEmpty
275
-     * returns true if there are no objects within the Collection, and false if there are
276
-     *
277
-     * @return bool
278
-     */
279
-    public function isEmpty()
280
-    {
281
-        return $this->count() === 0;
282
-    }
283
-
284
-
285
-    /**
286
-     * remove
287
-     * detaches an object from the Collection
288
-     *
289
-     * @param $object
290
-     * @return bool
291
-     */
292
-    public function remove($object)
293
-    {
294
-        $this->detach($object);
295
-        return true;
296
-    }
297
-
298
-
299
-    /**
300
-     * setCurrent
301
-     * advances pointer to the object whose identifier matches that which was provided
302
-     *
303
-     * @param mixed $identifier
304
-     * @return boolean
305
-     */
306
-    public function setCurrent($identifier)
307
-    {
308
-        $this->rewind();
309
-        while ($this->valid()) {
310
-            if ($identifier === $this->getInfo()) {
311
-                return true;
312
-            }
313
-            $this->next();
314
-        }
315
-        return false;
316
-    }
317
-
318
-
319
-    /**
320
-     * setCurrentUsingObject
321
-     * advances pointer to the provided object
322
-     *
323
-     * @param $object
324
-     * @return boolean
325
-     */
326
-    public function setCurrentUsingObject($object)
327
-    {
328
-        $this->rewind();
329
-        while ($this->valid()) {
330
-            if ($this->current() === $object) {
331
-                return true;
332
-            }
333
-            $this->next();
334
-        }
335
-        return false;
336
-    }
337
-
338
-
339
-    /**
340
-     * Returns the object occupying the index before the current object,
341
-     * unless this is already the first object, in which case it just returns the first object
342
-     *
343
-     * @return mixed
344
-     */
345
-    public function previous()
346
-    {
347
-        $index = $this->indexOf($this->current());
348
-        if ($index === 0) {
349
-            return $this->current();
350
-        }
351
-        $index--;
352
-        return $this->objectAtIndex($index);
353
-    }
354
-
355
-
356
-    /**
357
-     * Returns the index of a given object, or false if not found
358
-     *
359
-     * @see https://stackoverflow.com/a/8736013
360
-     * @param $object
361
-     * @return boolean|int|string
362
-     */
363
-    public function indexOf($object)
364
-    {
365
-        if (! $this->contains($object)) {
366
-            return false;
367
-        }
368
-        foreach ($this as $index => $obj) {
369
-            if ($obj === $object) {
370
-                return $index;
371
-            }
372
-        }
373
-        return false;
374
-    }
375
-
376
-
377
-    /**
378
-     * Returns the object at the given index
379
-     *
380
-     * @see https://stackoverflow.com/a/8736013
381
-     * @param int $index
382
-     * @return mixed
383
-     */
384
-    public function objectAtIndex($index)
385
-    {
386
-        $iterator = new LimitIterator($this, $index, 1);
387
-        $iterator->rewind();
388
-        return $iterator->current();
389
-    }
390
-
391
-
392
-    /**
393
-     * Returns the sequence of objects as specified by the offset and length
394
-     *
395
-     * @see https://stackoverflow.com/a/8736013
396
-     * @param int $offset
397
-     * @param int $length
398
-     * @return array
399
-     */
400
-    public function slice($offset, $length)
401
-    {
402
-        $slice = array();
403
-        $iterator = new LimitIterator($this, $offset, $length);
404
-        foreach ($iterator as $object) {
405
-            $slice[] = $object;
406
-        }
407
-        return $slice;
408
-    }
409
-
410
-
411
-    /**
412
-     * Inserts an object at a certain point
413
-     *
414
-     * @see https://stackoverflow.com/a/8736013
415
-     * @param mixed $object A single object
416
-     * @param int   $index
417
-     * @param mixed $identifier
418
-     * @return bool
419
-     * @throws DuplicateCollectionIdentifierException
420
-     * @throws InvalidEntityException
421
-     */
422
-    public function insertObjectAt($object, $index, $identifier = null)
423
-    {
424
-        // check to ensure that objects don't already exist in the collection
425
-        if ($this->has($identifier)) {
426
-            throw new DuplicateCollectionIdentifierException($identifier);
427
-        }
428
-        // detach any objects at or past this index
429
-        $remaining_objects = array();
430
-        if ($index < $this->count()) {
431
-            $remaining_objects = $this->slice($index, $this->count() - $index);
432
-            foreach ($remaining_objects as $key => $remaining_object) {
433
-                // we need to grab the identifiers for each object and use them as keys
434
-                $remaining_objects[ $remaining_object->getInfo() ] = $remaining_object;
435
-                // and then remove the object from the current tracking array
436
-                unset($remaining_objects[ $key ]);
437
-                // and then remove it from the Collection
438
-                $this->detach($remaining_object);
439
-            }
440
-        }
441
-        // add the new object we're splicing in
442
-        $this->add($object, $identifier);
443
-        // attach the objects we previously detached
444
-        foreach ($remaining_objects as $key => $remaining_object) {
445
-            $this->add($remaining_object, $key);
446
-        }
447
-        return $this->contains($object);
448
-    }
449
-
450
-
451
-    /**
452
-     * Inserts an object (or an array of objects) at a certain point
453
-     *
454
-     * @see https://stackoverflow.com/a/8736013
455
-     * @param mixed $objects A single object or an array of objects
456
-     * @param int   $index
457
-     */
458
-    public function insertAt($objects, $index)
459
-    {
460
-        if (! is_array($objects)) {
461
-            $objects = array($objects);
462
-        }
463
-        // check to ensure that objects don't already exist in the collection
464
-        foreach ($objects as $key => $object) {
465
-            if ($this->contains($object)) {
466
-                unset($objects[ $key ]);
467
-            }
468
-        }
469
-        // do we have any objects left?
470
-        if (! $objects) {
471
-            return;
472
-        }
473
-        // detach any objects at or past this index
474
-        $remaining = array();
475
-        if ($index < $this->count()) {
476
-            $remaining = $this->slice($index, $this->count() - $index);
477
-            foreach ($remaining as $object) {
478
-                $this->detach($object);
479
-            }
480
-        }
481
-        // add the new objects we're splicing in
482
-        foreach ($objects as $object) {
483
-            $this->attach($object);
484
-        }
485
-        // attach the objects we previously detached
486
-        foreach ($remaining as $object) {
487
-            $this->attach($object);
488
-        }
489
-    }
490
-
491
-
492
-    /**
493
-     * Removes the object at the given index
494
-     *
495
-     * @see https://stackoverflow.com/a/8736013
496
-     * @param int $index
497
-     */
498
-    public function removeAt($index)
499
-    {
500
-        $this->detach($this->objectAtIndex($index));
501
-    }
502
-
503
-
504
-    /**
505
-     * detaches ALL objects from the Collection
506
-     */
507
-    public function detachAll()
508
-    {
509
-        $this->rewind();
510
-        while ($this->valid()) {
511
-            $object = $this->current();
512
-            $this->next();
513
-            $this->detach($object);
514
-        }
515
-    }
516
-
517
-
518
-    /**
519
-     * unsets and detaches ALL objects from the Collection
520
-     */
521
-    public function trashAndDetachAll()
522
-    {
523
-        $this->rewind();
524
-        while ($this->valid()) {
525
-            $object = $this->current();
526
-            $this->next();
527
-            $this->detach($object);
528
-            unset($object);
529
-        }
530
-    }
21
+	/**
22
+	 * a unique string for identifying this collection
23
+	 *
24
+	 * @type string $collection_identifier
25
+	 */
26
+	protected $collection_identifier;
27
+
28
+
29
+	/**
30
+	 * an interface (or class) name to be used for restricting the type of objects added to the storage
31
+	 * this should be set from within the child class constructor
32
+	 *
33
+	 * @type string $interface
34
+	 */
35
+	protected $collection_interface;
36
+
37
+	/**
38
+	 * a short dash separated string describing the contents of this collection
39
+	 * used as the base for the $collection_identifier
40
+	 * defaults to the class short name if not set
41
+	 *
42
+	 * @type string $collection_identifier
43
+	 */
44
+	protected $collection_name;
45
+
46
+
47
+	/**
48
+	 * Collection constructor
49
+	 *
50
+	 * @param string $collection_interface
51
+	 * @param string $collection_name
52
+	 * @throws InvalidInterfaceException
53
+	 */
54
+	public function __construct($collection_interface, $collection_name = '')
55
+	{
56
+		$this->setCollectionInterface($collection_interface);
57
+		$this->setCollectionName($collection_name);
58
+		$this->setCollectionIdentifier();
59
+	}
60
+
61
+
62
+	/**
63
+	 * @return string
64
+	 * @since 4.10.33.p
65
+	 */
66
+	public function collectionInterface(): string
67
+	{
68
+		return $this->collection_interface;
69
+	}
70
+
71
+
72
+	/**
73
+	 * setCollectionInterface
74
+	 *
75
+	 * @param  string $collection_interface
76
+	 * @throws InvalidInterfaceException
77
+	 */
78
+	protected function setCollectionInterface($collection_interface)
79
+	{
80
+		if (! (interface_exists($collection_interface) || class_exists($collection_interface))) {
81
+			throw new InvalidInterfaceException($collection_interface);
82
+		}
83
+		$this->collection_interface = $collection_interface;
84
+	}
85
+
86
+
87
+	/**
88
+	 * @return string
89
+	 */
90
+	public function collectionName()
91
+	{
92
+		return $this->collection_name;
93
+	}
94
+
95
+
96
+	/**
97
+	 * @param string $collection_name
98
+	 */
99
+	protected function setCollectionName($collection_name)
100
+	{
101
+		$this->collection_name = ! empty($collection_name)
102
+			? sanitize_key($collection_name)
103
+			: basename(str_replace('\\', '/', get_class($this)));
104
+	}
105
+
106
+
107
+	/**
108
+	 * @return string
109
+	 */
110
+	public function collectionIdentifier()
111
+	{
112
+		return $this->collection_identifier;
113
+	}
114
+
115
+
116
+	/**
117
+	 * creates a very readable unique 9 character identifier like:  CF2-532-DAC
118
+	 * and appends it to the non-qualified class name, ex: ThingCollection-CF2-532-DAC
119
+	 *
120
+	 * @return void
121
+	 */
122
+	protected function setCollectionIdentifier()
123
+	{
124
+		// hash a few collection details
125
+		$identifier = md5(spl_object_hash($this) . $this->collection_interface . time());
126
+		// grab a few characters from the start, middle, and end of the hash
127
+		$id = array();
128
+		for ($x = 0; $x < 19; $x += 9) {
129
+			$id[] = substr($identifier, $x, 3);
130
+		}
131
+		$this->collection_identifier = $this->collection_name . '-' . strtoupper(implode('-', $id));
132
+	}
133
+
134
+
135
+	/**
136
+	 * add
137
+	 * attaches an object to the Collection
138
+	 * and sets any supplied data associated with the current iterator entry
139
+	 * by calling EE_Object_Collection::set_identifier()
140
+	 *
141
+	 * @param        $object
142
+	 * @param  mixed $identifier
143
+	 * @return bool
144
+	 * @throws InvalidEntityException
145
+	 * @throws DuplicateCollectionIdentifierException
146
+	 */
147
+	public function add($object, $identifier = null)
148
+	{
149
+		if (! $object instanceof $this->collection_interface) {
150
+			throw new InvalidEntityException($object, $this->collection_interface);
151
+		}
152
+		if ($this->contains($object)) {
153
+			throw new DuplicateCollectionIdentifierException($identifier);
154
+		}
155
+		$this->attach($object);
156
+		$this->setIdentifier($object, $identifier);
157
+		return $this->contains($object);
158
+	}
159
+
160
+
161
+	/**
162
+	 * getIdentifier
163
+	 * if no $identifier is supplied, then the spl_object_hash() is used
164
+	 *
165
+	 * @param        $object
166
+	 * @param  mixed $identifier
167
+	 * @return string
168
+	 */
169
+	public function getIdentifier($object, $identifier = null)
170
+	{
171
+		return ! empty($identifier)
172
+			? $identifier
173
+			: spl_object_hash($object);
174
+	}
175
+
176
+
177
+	/**
178
+	 * setIdentifier
179
+	 * Sets the data associated with an object in the Collection
180
+	 * if no $identifier is supplied, then the spl_object_hash() is used
181
+	 *
182
+	 * @param        $object
183
+	 * @param  mixed $identifier
184
+	 * @return bool
185
+	 */
186
+	public function setIdentifier($object, $identifier = null)
187
+	{
188
+		$identifier = $this->getIdentifier($object, $identifier);
189
+		$this->rewind();
190
+		while ($this->valid()) {
191
+			if ($object === $this->current()) {
192
+				$this->setInfo($identifier);
193
+				$this->rewind();
194
+				return true;
195
+			}
196
+			$this->next();
197
+		}
198
+		return false;
199
+	}
200
+
201
+
202
+	/**
203
+	 * get
204
+	 * finds and returns an object in the Collection based on the identifier that was set using addObject()
205
+	 * PLZ NOTE: the pointer is reset to the beginning of the collection before returning
206
+	 *
207
+	 * @param mixed $identifier
208
+	 * @return mixed
209
+	 */
210
+	public function get($identifier)
211
+	{
212
+		$this->rewind();
213
+		while ($this->valid()) {
214
+			if ($identifier === $this->getInfo()) {
215
+				$object = $this->current();
216
+				$this->rewind();
217
+				return $object;
218
+			}
219
+			$this->next();
220
+		}
221
+		return null;
222
+	}
223
+
224
+
225
+	/**
226
+	 * has
227
+	 * returns TRUE or FALSE
228
+	 * depending on whether the object is within the Collection
229
+	 * based on the supplied $identifier
230
+	 *
231
+	 * @param  mixed $identifier
232
+	 * @return bool
233
+	 */
234
+	public function has($identifier)
235
+	{
236
+		$this->rewind();
237
+		while ($this->valid()) {
238
+			if ($identifier === $this->getInfo()) {
239
+				$this->rewind();
240
+				return true;
241
+			}
242
+			$this->next();
243
+		}
244
+		return false;
245
+	}
246
+
247
+
248
+	/**
249
+	 * hasObject
250
+	 * returns TRUE or FALSE depending on whether the supplied object is within the Collection
251
+	 *
252
+	 * @param $object
253
+	 * @return bool
254
+	 */
255
+	public function hasObject($object)
256
+	{
257
+		return $this->contains($object);
258
+	}
259
+
260
+
261
+	/**
262
+	 * hasObjects
263
+	 * returns true if there are objects within the Collection, and false if it is empty
264
+	 *
265
+	 * @return bool
266
+	 */
267
+	public function hasObjects()
268
+	{
269
+		return $this->count() !== 0;
270
+	}
271
+
272
+
273
+	/**
274
+	 * isEmpty
275
+	 * returns true if there are no objects within the Collection, and false if there are
276
+	 *
277
+	 * @return bool
278
+	 */
279
+	public function isEmpty()
280
+	{
281
+		return $this->count() === 0;
282
+	}
283
+
284
+
285
+	/**
286
+	 * remove
287
+	 * detaches an object from the Collection
288
+	 *
289
+	 * @param $object
290
+	 * @return bool
291
+	 */
292
+	public function remove($object)
293
+	{
294
+		$this->detach($object);
295
+		return true;
296
+	}
297
+
298
+
299
+	/**
300
+	 * setCurrent
301
+	 * advances pointer to the object whose identifier matches that which was provided
302
+	 *
303
+	 * @param mixed $identifier
304
+	 * @return boolean
305
+	 */
306
+	public function setCurrent($identifier)
307
+	{
308
+		$this->rewind();
309
+		while ($this->valid()) {
310
+			if ($identifier === $this->getInfo()) {
311
+				return true;
312
+			}
313
+			$this->next();
314
+		}
315
+		return false;
316
+	}
317
+
318
+
319
+	/**
320
+	 * setCurrentUsingObject
321
+	 * advances pointer to the provided object
322
+	 *
323
+	 * @param $object
324
+	 * @return boolean
325
+	 */
326
+	public function setCurrentUsingObject($object)
327
+	{
328
+		$this->rewind();
329
+		while ($this->valid()) {
330
+			if ($this->current() === $object) {
331
+				return true;
332
+			}
333
+			$this->next();
334
+		}
335
+		return false;
336
+	}
337
+
338
+
339
+	/**
340
+	 * Returns the object occupying the index before the current object,
341
+	 * unless this is already the first object, in which case it just returns the first object
342
+	 *
343
+	 * @return mixed
344
+	 */
345
+	public function previous()
346
+	{
347
+		$index = $this->indexOf($this->current());
348
+		if ($index === 0) {
349
+			return $this->current();
350
+		}
351
+		$index--;
352
+		return $this->objectAtIndex($index);
353
+	}
354
+
355
+
356
+	/**
357
+	 * Returns the index of a given object, or false if not found
358
+	 *
359
+	 * @see https://stackoverflow.com/a/8736013
360
+	 * @param $object
361
+	 * @return boolean|int|string
362
+	 */
363
+	public function indexOf($object)
364
+	{
365
+		if (! $this->contains($object)) {
366
+			return false;
367
+		}
368
+		foreach ($this as $index => $obj) {
369
+			if ($obj === $object) {
370
+				return $index;
371
+			}
372
+		}
373
+		return false;
374
+	}
375
+
376
+
377
+	/**
378
+	 * Returns the object at the given index
379
+	 *
380
+	 * @see https://stackoverflow.com/a/8736013
381
+	 * @param int $index
382
+	 * @return mixed
383
+	 */
384
+	public function objectAtIndex($index)
385
+	{
386
+		$iterator = new LimitIterator($this, $index, 1);
387
+		$iterator->rewind();
388
+		return $iterator->current();
389
+	}
390
+
391
+
392
+	/**
393
+	 * Returns the sequence of objects as specified by the offset and length
394
+	 *
395
+	 * @see https://stackoverflow.com/a/8736013
396
+	 * @param int $offset
397
+	 * @param int $length
398
+	 * @return array
399
+	 */
400
+	public function slice($offset, $length)
401
+	{
402
+		$slice = array();
403
+		$iterator = new LimitIterator($this, $offset, $length);
404
+		foreach ($iterator as $object) {
405
+			$slice[] = $object;
406
+		}
407
+		return $slice;
408
+	}
409
+
410
+
411
+	/**
412
+	 * Inserts an object at a certain point
413
+	 *
414
+	 * @see https://stackoverflow.com/a/8736013
415
+	 * @param mixed $object A single object
416
+	 * @param int   $index
417
+	 * @param mixed $identifier
418
+	 * @return bool
419
+	 * @throws DuplicateCollectionIdentifierException
420
+	 * @throws InvalidEntityException
421
+	 */
422
+	public function insertObjectAt($object, $index, $identifier = null)
423
+	{
424
+		// check to ensure that objects don't already exist in the collection
425
+		if ($this->has($identifier)) {
426
+			throw new DuplicateCollectionIdentifierException($identifier);
427
+		}
428
+		// detach any objects at or past this index
429
+		$remaining_objects = array();
430
+		if ($index < $this->count()) {
431
+			$remaining_objects = $this->slice($index, $this->count() - $index);
432
+			foreach ($remaining_objects as $key => $remaining_object) {
433
+				// we need to grab the identifiers for each object and use them as keys
434
+				$remaining_objects[ $remaining_object->getInfo() ] = $remaining_object;
435
+				// and then remove the object from the current tracking array
436
+				unset($remaining_objects[ $key ]);
437
+				// and then remove it from the Collection
438
+				$this->detach($remaining_object);
439
+			}
440
+		}
441
+		// add the new object we're splicing in
442
+		$this->add($object, $identifier);
443
+		// attach the objects we previously detached
444
+		foreach ($remaining_objects as $key => $remaining_object) {
445
+			$this->add($remaining_object, $key);
446
+		}
447
+		return $this->contains($object);
448
+	}
449
+
450
+
451
+	/**
452
+	 * Inserts an object (or an array of objects) at a certain point
453
+	 *
454
+	 * @see https://stackoverflow.com/a/8736013
455
+	 * @param mixed $objects A single object or an array of objects
456
+	 * @param int   $index
457
+	 */
458
+	public function insertAt($objects, $index)
459
+	{
460
+		if (! is_array($objects)) {
461
+			$objects = array($objects);
462
+		}
463
+		// check to ensure that objects don't already exist in the collection
464
+		foreach ($objects as $key => $object) {
465
+			if ($this->contains($object)) {
466
+				unset($objects[ $key ]);
467
+			}
468
+		}
469
+		// do we have any objects left?
470
+		if (! $objects) {
471
+			return;
472
+		}
473
+		// detach any objects at or past this index
474
+		$remaining = array();
475
+		if ($index < $this->count()) {
476
+			$remaining = $this->slice($index, $this->count() - $index);
477
+			foreach ($remaining as $object) {
478
+				$this->detach($object);
479
+			}
480
+		}
481
+		// add the new objects we're splicing in
482
+		foreach ($objects as $object) {
483
+			$this->attach($object);
484
+		}
485
+		// attach the objects we previously detached
486
+		foreach ($remaining as $object) {
487
+			$this->attach($object);
488
+		}
489
+	}
490
+
491
+
492
+	/**
493
+	 * Removes the object at the given index
494
+	 *
495
+	 * @see https://stackoverflow.com/a/8736013
496
+	 * @param int $index
497
+	 */
498
+	public function removeAt($index)
499
+	{
500
+		$this->detach($this->objectAtIndex($index));
501
+	}
502
+
503
+
504
+	/**
505
+	 * detaches ALL objects from the Collection
506
+	 */
507
+	public function detachAll()
508
+	{
509
+		$this->rewind();
510
+		while ($this->valid()) {
511
+			$object = $this->current();
512
+			$this->next();
513
+			$this->detach($object);
514
+		}
515
+	}
516
+
517
+
518
+	/**
519
+	 * unsets and detaches ALL objects from the Collection
520
+	 */
521
+	public function trashAndDetachAll()
522
+	{
523
+		$this->rewind();
524
+		while ($this->valid()) {
525
+			$object = $this->current();
526
+			$this->next();
527
+			$this->detach($object);
528
+			unset($object);
529
+		}
530
+	}
531 531
 }
Please login to merge, or discard this patch.
core/services/session/SessionStartHandler.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         }
100 100
         // If not, then attempt to deal with any errors,
101 101
         // otherwise, try to hobble along without the session
102
-        if (! $this->handleSessionSaveHandlerErrors()) {
102
+        if ( ! $this->handleSessionSaveHandlerErrors()) {
103 103
             return;
104 104
         }
105 105
         // there is no record of a fatal error while trying to start the session
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
                     ),
250 250
                     '<a href="https://wordpress.org/plugins/wp-native-php-sessions/">',
251 251
                     '</a>',
252
-                    '<a href="' . $retry_session_url . '">'
252
+                    '<a href="'.$retry_session_url.'">'
253 253
                 ),
254 254
                 __FILE__,
255 255
                 __FUNCTION__,
Please login to merge, or discard this patch.
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -27,237 +27,237 @@
 block discarded – undo
27 27
  */
28 28
 class SessionStartHandler
29 29
 {
30
-    const OPTION_NAME_SESSION_SAVE_HANDLER_STATUS = 'ee_session_save_handler_status';
31
-    const REQUEST_PARAM_RETRY_SESSION = 'ee_retry_session';
32
-    const SESSION_SAVE_HANDLER_STATUS_FAILED = 'session_save_handler_failed';
33
-    const SESSION_SAVE_HANDLER_STATUS_SUCCESS = 'session_save_handler_success';
34
-    const SESSION_SAVE_HANDLER_STATUS_UNKNOWN = 'session_save_handler_untested';
30
+	const OPTION_NAME_SESSION_SAVE_HANDLER_STATUS = 'ee_session_save_handler_status';
31
+	const REQUEST_PARAM_RETRY_SESSION = 'ee_retry_session';
32
+	const SESSION_SAVE_HANDLER_STATUS_FAILED = 'session_save_handler_failed';
33
+	const SESSION_SAVE_HANDLER_STATUS_SUCCESS = 'session_save_handler_success';
34
+	const SESSION_SAVE_HANDLER_STATUS_UNKNOWN = 'session_save_handler_untested';
35 35
 
36
-    /**
37
-     * @var RequestInterface $request
38
-     */
39
-    protected $request;
36
+	/**
37
+	 * @var RequestInterface $request
38
+	 */
39
+	protected $request;
40 40
 
41
-    /**
42
-     * StartSession constructor.
43
-     *
44
-     * @param RequestInterface $request
45
-     */
46
-    public function __construct(RequestInterface $request)
47
-    {
48
-        $this->request = $request;
49
-    }
41
+	/**
42
+	 * StartSession constructor.
43
+	 *
44
+	 * @param RequestInterface $request
45
+	 */
46
+	public function __construct(RequestInterface $request)
47
+	{
48
+		$this->request = $request;
49
+	}
50 50
 
51
-    /**
52
-     * Check if a custom session save handler is in play
53
-     * and attempt to start the PHP session
54
-     *
55
-     * @since 4.9.68.p
56
-     */
57
-    public function startSession()
58
-    {
59
-        // check that session has started
60
-        if (session_id() === '') {
61
-            // starts a new session if one doesn't already exist, or re-initiates an existing one
62
-            if ($this->hasKnownCustomSessionSaveHandler()) {
63
-                $this->checkCustomSessionSaveHandler();
64
-            } else {
65
-                session_start();
66
-                session_write_close();
67
-            }
68
-        }
69
-    }
51
+	/**
52
+	 * Check if a custom session save handler is in play
53
+	 * and attempt to start the PHP session
54
+	 *
55
+	 * @since 4.9.68.p
56
+	 */
57
+	public function startSession()
58
+	{
59
+		// check that session has started
60
+		if (session_id() === '') {
61
+			// starts a new session if one doesn't already exist, or re-initiates an existing one
62
+			if ($this->hasKnownCustomSessionSaveHandler()) {
63
+				$this->checkCustomSessionSaveHandler();
64
+			} else {
65
+				session_start();
66
+				session_write_close();
67
+			}
68
+		}
69
+	}
70 70
 
71
-    /**
72
-     * Returns `true` if the 'session.save_handler' ini setting matches a known custom handler
73
-     *
74
-     * @since 4.9.68.p
75
-     * @return bool
76
-     */
77
-    private function hasKnownCustomSessionSaveHandler()
78
-    {
79
-        return in_array(
80
-            ini_get('session.save_handler'),
81
-            array(
82
-                'user',
83
-            ),
84
-            true
85
-        );
86
-    }
71
+	/**
72
+	 * Returns `true` if the 'session.save_handler' ini setting matches a known custom handler
73
+	 *
74
+	 * @since 4.9.68.p
75
+	 * @return bool
76
+	 */
77
+	private function hasKnownCustomSessionSaveHandler()
78
+	{
79
+		return in_array(
80
+			ini_get('session.save_handler'),
81
+			array(
82
+				'user',
83
+			),
84
+			true
85
+		);
86
+	}
87 87
 
88
-    /**
89
-     * Attempt to start the PHP session when a custom Session Save Handler is known to be set.
90
-     *
91
-     * @since 4.9.68.p
92
-     */
93
-    private function checkCustomSessionSaveHandler()
94
-    {
95
-        // If we've already successfully tested the session save handler
96
-        // on a previous request then just start the session
97
-        if ($this->sessionSaveHandlerIsValid()) {
98
-            session_start();
99
-            session_write_close();
100
-            return;
101
-        }
102
-        // If not, then attempt to deal with any errors,
103
-        // otherwise, try to hobble along without the session
104
-        if (! $this->handleSessionSaveHandlerErrors()) {
105
-            return;
106
-        }
107
-        // there is no record of a fatal error while trying to start the session
108
-        // so let's see if there's a custom session save handler. Proceed with caution
109
-        $this->initializeSessionSaveHandlerStatus();
110
-        // hold your breath, the custom session save handler might cause a fatal here...
111
-        session_start();
112
-        session_write_close();
113
-        // phew! we made it! the custom session handler is a-ok
114
-        $this->setSessionSaveHandlerStatusToValid();
115
-    }
88
+	/**
89
+	 * Attempt to start the PHP session when a custom Session Save Handler is known to be set.
90
+	 *
91
+	 * @since 4.9.68.p
92
+	 */
93
+	private function checkCustomSessionSaveHandler()
94
+	{
95
+		// If we've already successfully tested the session save handler
96
+		// on a previous request then just start the session
97
+		if ($this->sessionSaveHandlerIsValid()) {
98
+			session_start();
99
+			session_write_close();
100
+			return;
101
+		}
102
+		// If not, then attempt to deal with any errors,
103
+		// otherwise, try to hobble along without the session
104
+		if (! $this->handleSessionSaveHandlerErrors()) {
105
+			return;
106
+		}
107
+		// there is no record of a fatal error while trying to start the session
108
+		// so let's see if there's a custom session save handler. Proceed with caution
109
+		$this->initializeSessionSaveHandlerStatus();
110
+		// hold your breath, the custom session save handler might cause a fatal here...
111
+		session_start();
112
+		session_write_close();
113
+		// phew! we made it! the custom session handler is a-ok
114
+		$this->setSessionSaveHandlerStatusToValid();
115
+	}
116 116
 
117 117
 
118
-    /**
119
-     * retrieves the value for the 'ee_session_save_handler_status' WP option.
120
-     * default value = 'session_save_handler_untested'
121
-     *
122
-     * @since 4.9.68.p
123
-     * @return string
124
-     */
125
-    private function getSessionSaveHandlerStatus()
126
-    {
127
-        return get_option(
128
-            SessionStartHandler::OPTION_NAME_SESSION_SAVE_HANDLER_STATUS,
129
-            SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_UNKNOWN
130
-        );
131
-    }
118
+	/**
119
+	 * retrieves the value for the 'ee_session_save_handler_status' WP option.
120
+	 * default value = 'session_save_handler_untested'
121
+	 *
122
+	 * @since 4.9.68.p
123
+	 * @return string
124
+	 */
125
+	private function getSessionSaveHandlerStatus()
126
+	{
127
+		return get_option(
128
+			SessionStartHandler::OPTION_NAME_SESSION_SAVE_HANDLER_STATUS,
129
+			SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_UNKNOWN
130
+		);
131
+	}
132 132
 
133
-    /**
134
-     * Sets the 'ee_session_save_handler_status' WP option value to 'session_save_handler_failed'
135
-     * which can then be upgraded is everything works correctly
136
-     *
137
-     * @since 4.9.68.p
138
-     * @return bool
139
-     */
140
-    private function initializeSessionSaveHandlerStatus()
141
-    {
142
-        return update_option(
143
-            SessionStartHandler::OPTION_NAME_SESSION_SAVE_HANDLER_STATUS,
144
-            SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_FAILED
145
-        );
146
-    }
133
+	/**
134
+	 * Sets the 'ee_session_save_handler_status' WP option value to 'session_save_handler_failed'
135
+	 * which can then be upgraded is everything works correctly
136
+	 *
137
+	 * @since 4.9.68.p
138
+	 * @return bool
139
+	 */
140
+	private function initializeSessionSaveHandlerStatus()
141
+	{
142
+		return update_option(
143
+			SessionStartHandler::OPTION_NAME_SESSION_SAVE_HANDLER_STATUS,
144
+			SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_FAILED
145
+		);
146
+	}
147 147
 
148
-    /**
149
-     * Sets the 'ee_session_save_handler_status' WP option value to 'session_save_handler_success'
150
-     *
151
-     * @since 4.9.68.p
152
-     * @return bool
153
-     */
154
-    private function setSessionSaveHandlerStatusToValid()
155
-    {
156
-        return update_option(
157
-            SessionStartHandler::OPTION_NAME_SESSION_SAVE_HANDLER_STATUS,
158
-            SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_SUCCESS
159
-        );
160
-    }
148
+	/**
149
+	 * Sets the 'ee_session_save_handler_status' WP option value to 'session_save_handler_success'
150
+	 *
151
+	 * @since 4.9.68.p
152
+	 * @return bool
153
+	 */
154
+	private function setSessionSaveHandlerStatusToValid()
155
+	{
156
+		return update_option(
157
+			SessionStartHandler::OPTION_NAME_SESSION_SAVE_HANDLER_STATUS,
158
+			SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_SUCCESS
159
+		);
160
+	}
161 161
 
162
-    /**
163
-     * Sets the 'ee_session_save_handler_status' WP option value to 'session_save_handler_untested'
164
-     *
165
-     * @since 4.9.68.p
166
-     * @return bool
167
-     */
168
-    private function resetSessionSaveHandlerStatus()
169
-    {
170
-        return update_option(
171
-            SessionStartHandler::OPTION_NAME_SESSION_SAVE_HANDLER_STATUS,
172
-            SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_UNKNOWN
173
-        );
174
-    }
162
+	/**
163
+	 * Sets the 'ee_session_save_handler_status' WP option value to 'session_save_handler_untested'
164
+	 *
165
+	 * @since 4.9.68.p
166
+	 * @return bool
167
+	 */
168
+	private function resetSessionSaveHandlerStatus()
169
+	{
170
+		return update_option(
171
+			SessionStartHandler::OPTION_NAME_SESSION_SAVE_HANDLER_STATUS,
172
+			SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_UNKNOWN
173
+		);
174
+	}
175 175
 
176
-    /**
177
-     * Returns `true` if the 'ee_session_save_handler_status' WP option value
178
-     * is equal to 'session_save_handler_success'
179
-     *
180
-     * @since 4.9.68.p
181
-     * @return bool
182
-     */
183
-    private function sessionSaveHandlerIsValid()
184
-    {
185
-        return $this->getSessionSaveHandlerStatus() === SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_SUCCESS;
186
-    }
176
+	/**
177
+	 * Returns `true` if the 'ee_session_save_handler_status' WP option value
178
+	 * is equal to 'session_save_handler_success'
179
+	 *
180
+	 * @since 4.9.68.p
181
+	 * @return bool
182
+	 */
183
+	private function sessionSaveHandlerIsValid()
184
+	{
185
+		return $this->getSessionSaveHandlerStatus() === SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_SUCCESS;
186
+	}
187 187
 
188
-    /**
189
-     * Returns `true` if the 'ee_session_save_handler_status' WP option value
190
-     * is equal to 'session_save_handler_failed'
191
-     *
192
-     * @since 4.9.68.p
193
-     * @return bool
194
-     */
195
-    private function sessionSaveHandlerFailed()
196
-    {
197
-        return $this->getSessionSaveHandlerStatus() === SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_FAILED;
198
-    }
188
+	/**
189
+	 * Returns `true` if the 'ee_session_save_handler_status' WP option value
190
+	 * is equal to 'session_save_handler_failed'
191
+	 *
192
+	 * @since 4.9.68.p
193
+	 * @return bool
194
+	 */
195
+	private function sessionSaveHandlerFailed()
196
+	{
197
+		return $this->getSessionSaveHandlerStatus() === SessionStartHandler::SESSION_SAVE_HANDLER_STATUS_FAILED;
198
+	}
199 199
 
200
-    /**
201
-     * Returns `true` if no errors were detected with the session save handler,
202
-     * otherwise attempts to work notify the appropriate authorities
203
-     * with a suggestion for how to fix the issue, and returns `false`.
204
-     *
205
-     *
206
-     * @since 4.9.68.p
207
-     * @return bool
208
-     */
209
-    private function handleSessionSaveHandlerErrors()
210
-    {
211
-        // Check if we had a fatal error last time while trying to start the session
212
-        if ($this->sessionSaveHandlerFailed()) {
213
-            // apparently, last time we tried using the custom session save handler there was a fatal
214
-            if ($this->request->requestParamIsSet(SessionStartHandler::REQUEST_PARAM_RETRY_SESSION)) {
215
-                $this->resetSessionSaveHandlerStatus();
216
-                // remove "ee_retry_session", otherwise if the problem still isn't fixed,
217
-                // we'll just keep getting the fatal error over and over.
218
-                // Better to remove it and redirect, and try on the next request
219
-                EEH_URL::safeRedirectAndExit(
220
-                    remove_query_arg(
221
-                        array(SessionStartHandler::REQUEST_PARAM_RETRY_SESSION),
222
-                        EEH_URL::current_url()
223
-                    )
224
-                );
225
-            }
226
-            // so the session is broken, don't try it again,
227
-            // just show a message to users that can fix it
228
-            $this->displaySessionSaveHandlerErrorNotice();
229
-            return false;
230
-        }
231
-        return true;
232
-    }
200
+	/**
201
+	 * Returns `true` if no errors were detected with the session save handler,
202
+	 * otherwise attempts to work notify the appropriate authorities
203
+	 * with a suggestion for how to fix the issue, and returns `false`.
204
+	 *
205
+	 *
206
+	 * @since 4.9.68.p
207
+	 * @return bool
208
+	 */
209
+	private function handleSessionSaveHandlerErrors()
210
+	{
211
+		// Check if we had a fatal error last time while trying to start the session
212
+		if ($this->sessionSaveHandlerFailed()) {
213
+			// apparently, last time we tried using the custom session save handler there was a fatal
214
+			if ($this->request->requestParamIsSet(SessionStartHandler::REQUEST_PARAM_RETRY_SESSION)) {
215
+				$this->resetSessionSaveHandlerStatus();
216
+				// remove "ee_retry_session", otherwise if the problem still isn't fixed,
217
+				// we'll just keep getting the fatal error over and over.
218
+				// Better to remove it and redirect, and try on the next request
219
+				EEH_URL::safeRedirectAndExit(
220
+					remove_query_arg(
221
+						array(SessionStartHandler::REQUEST_PARAM_RETRY_SESSION),
222
+						EEH_URL::current_url()
223
+					)
224
+				);
225
+			}
226
+			// so the session is broken, don't try it again,
227
+			// just show a message to users that can fix it
228
+			$this->displaySessionSaveHandlerErrorNotice();
229
+			return false;
230
+		}
231
+		return true;
232
+	}
233 233
 
234
-    /**
235
-     * Generates an EE_Error notice regarding the current session woes
236
-     * but only if the current user is an admin with permission to 'install_plugins'.
237
-     *
238
-     * @since 4.9.68.p
239
-     */
240
-    private function displaySessionSaveHandlerErrorNotice()
241
-    {
242
-        if (current_user_can('install_plugins')) {
243
-            $retry_session_url = add_query_arg(
244
-                array(SessionStartHandler::REQUEST_PARAM_RETRY_SESSION => true),
245
-                EEH_URL::current_url()
246
-            );
247
-            EE_Error::add_error(
248
-                sprintf(
249
-                    esc_html__(
250
-                        'It appears there was a fatal error while starting the session, so Event Espresso is not able to process registrations normally. Some hosting companies, like Pantheon, require an extra plugin for Event Espresso to work. Please install the %1$sWordPress Native PHP Sessions plugin%2$s, then %3$sclick here to check if the problem is resolved.%2$s',
251
-                        'event_espresso'
252
-                    ),
253
-                    '<a href="https://wordpress.org/plugins/wp-native-php-sessions/">',
254
-                    '</a>',
255
-                    '<a href="' . $retry_session_url . '">'
256
-                ),
257
-                __FILE__,
258
-                __FUNCTION__,
259
-                __LINE__
260
-            );
261
-        }
262
-    }
234
+	/**
235
+	 * Generates an EE_Error notice regarding the current session woes
236
+	 * but only if the current user is an admin with permission to 'install_plugins'.
237
+	 *
238
+	 * @since 4.9.68.p
239
+	 */
240
+	private function displaySessionSaveHandlerErrorNotice()
241
+	{
242
+		if (current_user_can('install_plugins')) {
243
+			$retry_session_url = add_query_arg(
244
+				array(SessionStartHandler::REQUEST_PARAM_RETRY_SESSION => true),
245
+				EEH_URL::current_url()
246
+			);
247
+			EE_Error::add_error(
248
+				sprintf(
249
+					esc_html__(
250
+						'It appears there was a fatal error while starting the session, so Event Espresso is not able to process registrations normally. Some hosting companies, like Pantheon, require an extra plugin for Event Espresso to work. Please install the %1$sWordPress Native PHP Sessions plugin%2$s, then %3$sclick here to check if the problem is resolved.%2$s',
251
+						'event_espresso'
252
+					),
253
+					'<a href="https://wordpress.org/plugins/wp-native-php-sessions/">',
254
+					'</a>',
255
+					'<a href="' . $retry_session_url . '">'
256
+				),
257
+				__FILE__,
258
+				__FUNCTION__,
259
+				__LINE__
260
+			);
261
+		}
262
+	}
263 263
 }
Please login to merge, or discard this patch.
core/services/dependencies/ClassAlias.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
      */
35 35
     public function __construct($alias, $fqcn)
36 36
     {
37
-        if (! is_subclass_of($fqcn, $alias)) {
37
+        if ( ! is_subclass_of($fqcn, $alias)) {
38 38
             throw new InvalidAliasException($fqcn, $alias);
39 39
         }
40 40
         $this->alias = $alias;
Please login to merge, or discard this patch.
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -16,46 +16,46 @@
 block discarded – undo
16 16
  */
17 17
 class ClassAlias
18 18
 {
19
-    /**
20
-     * @var string $alias   an interface or base class representing what object
21
-     *                      can be utilized by another object and/or function
22
-     */
23
-    private $alias;
19
+	/**
20
+	 * @var string $alias   an interface or base class representing what object
21
+	 *                      can be utilized by another object and/or function
22
+	 */
23
+	private $alias;
24 24
 
25
-    /**
26
-     * @var string $fqcn the actual class that should be substituted for the alias above
27
-     */
28
-    private $fqcn;
25
+	/**
26
+	 * @var string $fqcn the actual class that should be substituted for the alias above
27
+	 */
28
+	private $fqcn;
29 29
 
30
-    /**
31
-     * ClassAlias constructor.
32
-     *
33
-     * @param string $alias Interface specified by implementing class
34
-     * @param string $fqcn  Concrete class that satisfies interface
35
-     * @throws InvalidAliasException
36
-     */
37
-    public function __construct($alias, $fqcn)
38
-    {
39
-        if (! is_subclass_of($fqcn, $alias)) {
40
-            throw new InvalidAliasException($fqcn, $alias);
41
-        }
42
-        $this->alias = $alias;
43
-        $this->fqcn = $fqcn;
44
-    }
30
+	/**
31
+	 * ClassAlias constructor.
32
+	 *
33
+	 * @param string $alias Interface specified by implementing class
34
+	 * @param string $fqcn  Concrete class that satisfies interface
35
+	 * @throws InvalidAliasException
36
+	 */
37
+	public function __construct($alias, $fqcn)
38
+	{
39
+		if (! is_subclass_of($fqcn, $alias)) {
40
+			throw new InvalidAliasException($fqcn, $alias);
41
+		}
42
+		$this->alias = $alias;
43
+		$this->fqcn = $fqcn;
44
+	}
45 45
 
46
-    /**
47
-     * @return string
48
-     */
49
-    public function alias()
50
-    {
51
-        return $this->alias;
52
-    }
46
+	/**
47
+	 * @return string
48
+	 */
49
+	public function alias()
50
+	{
51
+		return $this->alias;
52
+	}
53 53
 
54
-    /**
55
-     * @return string
56
-     */
57
-    public function fqcn()
58
-    {
59
-        return $this->fqcn;
60
-    }
54
+	/**
55
+	 * @return string
56
+	 */
57
+	public function fqcn()
58
+	{
59
+		return $this->fqcn;
60
+	}
61 61
 }
Please login to merge, or discard this patch.
core/services/factory/FactoryWithDependencyResolver.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -18,41 +18,41 @@
 block discarded – undo
18 18
  */
19 19
 abstract class FactoryWithDependencyResolver implements FactoryInterface
20 20
 {
21
-    /**
22
-     * @var DependencyResolverInterface $dependency_resolver
23
-     */
24
-    private $dependency_resolver;
21
+	/**
22
+	 * @var DependencyResolverInterface $dependency_resolver
23
+	 */
24
+	private $dependency_resolver;
25 25
 
26
-    /**
27
-     * @var LoaderInterface $loader
28
-     */
29
-    private $loader;
26
+	/**
27
+	 * @var LoaderInterface $loader
28
+	 */
29
+	private $loader;
30 30
 
31
-    /**
32
-     * FactoryWithDependencyResolver constructor.
33
-     *
34
-     * @param DependencyResolverInterface $dependency_resolver
35
-     * @param LoaderInterface             $loader
36
-     */
37
-    public function __construct(DependencyResolverInterface $dependency_resolver, LoaderInterface $loader)
38
-    {
39
-        $this->dependency_resolver = $dependency_resolver;
40
-        $this->loader = $loader;
41
-    }
31
+	/**
32
+	 * FactoryWithDependencyResolver constructor.
33
+	 *
34
+	 * @param DependencyResolverInterface $dependency_resolver
35
+	 * @param LoaderInterface             $loader
36
+	 */
37
+	public function __construct(DependencyResolverInterface $dependency_resolver, LoaderInterface $loader)
38
+	{
39
+		$this->dependency_resolver = $dependency_resolver;
40
+		$this->loader = $loader;
41
+	}
42 42
 
43
-    /**
44
-     * @return DependencyResolverInterface
45
-     */
46
-    public function dependencyResolver()
47
-    {
48
-        return $this->dependency_resolver;
49
-    }
43
+	/**
44
+	 * @return DependencyResolverInterface
45
+	 */
46
+	public function dependencyResolver()
47
+	{
48
+		return $this->dependency_resolver;
49
+	}
50 50
 
51
-    /**
52
-     * @return LoaderInterface
53
-     */
54
-    public function loader()
55
-    {
56
-        return $this->loader;
57
-    }
51
+	/**
52
+	 * @return LoaderInterface
53
+	 */
54
+	public function loader()
55
+	{
56
+		return $this->loader;
57
+	}
58 58
 }
Please login to merge, or discard this patch.
core/domain/entities/route_match/MatchAllRouteSpecifications.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
     public function isMatchingRoute()
24 24
     {
25 25
         foreach ($this->specifications as $specification) {
26
-            if (! $specification->isMatchingRoute()) {
26
+            if ( ! $specification->isMatchingRoute()) {
27 27
                 return false;
28 28
             }
29 29
         }
Please login to merge, or discard this patch.
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -13,19 +13,19 @@
 block discarded – undo
13 13
  */
14 14
 class MatchAllRouteSpecifications extends MultiRouteSpecification
15 15
 {
16
-    /**
17
-     * returns true if current request matches specification
18
-     *
19
-     * @since 4.9.71.p
20
-     * @return boolean
21
-     */
22
-    public function isMatchingRoute()
23
-    {
24
-        foreach ($this->specifications as $specification) {
25
-            if (! $specification->isMatchingRoute()) {
26
-                return false;
27
-            }
28
-        }
29
-        return true;
30
-    }
16
+	/**
17
+	 * returns true if current request matches specification
18
+	 *
19
+	 * @since 4.9.71.p
20
+	 * @return boolean
21
+	 */
22
+	public function isMatchingRoute()
23
+	{
24
+		foreach ($this->specifications as $specification) {
25
+			if (! $specification->isMatchingRoute()) {
26
+				return false;
27
+			}
28
+		}
29
+		return true;
30
+	}
31 31
 }
Please login to merge, or discard this patch.
core/services/route_match/RouteMatchSpecificationManager.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@
 block discarded – undo
115 115
     {
116 116
         /** @var RouteMatchSpecificationInterface $specification */
117 117
         $specification = $this->specifications->get($routeMatchSpecificationFqcn);
118
-        if (! $specification instanceof $routeMatchSpecificationFqcn) {
118
+        if ( ! $specification instanceof $routeMatchSpecificationFqcn) {
119 119
             throw new InvalidClassException($routeMatchSpecificationFqcn);
120 120
         }
121 121
         return $specification->isMatchingRoute();
Please login to merge, or discard this patch.
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -25,122 +25,122 @@
 block discarded – undo
25 25
  */
26 26
 class RouteMatchSpecificationManager
27 27
 {
28
-    /**
29
-     * @var CollectionInterface[]|RouteMatchSpecificationInterface[] $specifications
30
-     */
31
-    private $specifications;
28
+	/**
29
+	 * @var CollectionInterface[]|RouteMatchSpecificationInterface[] $specifications
30
+	 */
31
+	private $specifications;
32 32
 
33
-    /**
34
-     * @var RouteMatchSpecificationFactory $specifications_factory
35
-     */
36
-    private $specifications_factory;
33
+	/**
34
+	 * @var RouteMatchSpecificationFactory $specifications_factory
35
+	 */
36
+	private $specifications_factory;
37 37
 
38 38
 
39
-    /**
40
-     * RouteMatchSpecificationManager constructor.
41
-     *
42
-     * @param RouteMatchSpecificationCollection $specifications
43
-     * @param RouteMatchSpecificationFactory    $specifications_factory
44
-     */
45
-    public function __construct(
46
-        RouteMatchSpecificationCollection $specifications,
47
-        RouteMatchSpecificationFactory $specifications_factory
48
-    ) {
49
-        $this->specifications = $specifications;
50
-        $this->specifications_factory = $specifications_factory;
51
-        add_action('AHEE__EE_System__loadRouteMatchSpecifications', array($this, 'initialize'));
52
-    }
39
+	/**
40
+	 * RouteMatchSpecificationManager constructor.
41
+	 *
42
+	 * @param RouteMatchSpecificationCollection $specifications
43
+	 * @param RouteMatchSpecificationFactory    $specifications_factory
44
+	 */
45
+	public function __construct(
46
+		RouteMatchSpecificationCollection $specifications,
47
+		RouteMatchSpecificationFactory $specifications_factory
48
+	) {
49
+		$this->specifications = $specifications;
50
+		$this->specifications_factory = $specifications_factory;
51
+		add_action('AHEE__EE_System__loadRouteMatchSpecifications', array($this, 'initialize'));
52
+	}
53 53
 
54 54
 
55
-    /**
56
-     * Perform any early setup required for block editors to functions
57
-     *
58
-     * @return void
59
-     * @throws CollectionLoaderException
60
-     * @throws CollectionDetailsException
61
-     */
62
-    public function initialize()
63
-    {
64
-        $this->populateSpecificationCollection();
65
-    }
55
+	/**
56
+	 * Perform any early setup required for block editors to functions
57
+	 *
58
+	 * @return void
59
+	 * @throws CollectionLoaderException
60
+	 * @throws CollectionDetailsException
61
+	 */
62
+	public function initialize()
63
+	{
64
+		$this->populateSpecificationCollection();
65
+	}
66 66
 
67 67
 
68
-    /**
69
-     * @return CollectionInterface|RouteMatchSpecificationInterface[]
70
-     * @throws CollectionLoaderException
71
-     * @throws CollectionDetailsException
72
-     * @since 4.9.71.p
73
-     */
74
-    private function populateSpecificationCollection()
75
-    {
76
-        $loader = new CollectionLoader(
77
-            new CollectionDetails(
78
-                // collection name
79
-                RouteMatchSpecificationCollection::COLLECTION_NAME,
80
-                // collection interface
81
-                'EventEspresso\core\domain\entities\route_match\RouteMatchSpecificationInterface',
82
-                // FQCNs for classes to add (all classes within each namespace will be loaded)
83
-                apply_filters(
84
-                    'FHEE__EventEspresso_core_services_route_match_RouteMatchSpecificationManager__populateSpecificationCollection__collection_FQCNs',
85
-                    array(
86
-                        'EventEspresso\core\domain\entities\route_match\specifications\admin',
87
-                        'EventEspresso\core\domain\entities\route_match\specifications\frontend',
88
-                    )
89
-                ),
90
-                // filepaths to classes to add
91
-                array(),
92
-                // file mask to use if parsing folder for files to add
93
-                '',
94
-                // what to use as identifier for collection entities
95
-                // using CLASS NAME prevents duplicates (works like a singleton)
96
-                CollectionDetails::ID_CLASS_NAME
97
-            ),
98
-            $this->specifications,
99
-            null,
100
-            $this->specifications_factory
101
-        );
102
-        return $loader->getCollection();
103
-    }
68
+	/**
69
+	 * @return CollectionInterface|RouteMatchSpecificationInterface[]
70
+	 * @throws CollectionLoaderException
71
+	 * @throws CollectionDetailsException
72
+	 * @since 4.9.71.p
73
+	 */
74
+	private function populateSpecificationCollection()
75
+	{
76
+		$loader = new CollectionLoader(
77
+			new CollectionDetails(
78
+				// collection name
79
+				RouteMatchSpecificationCollection::COLLECTION_NAME,
80
+				// collection interface
81
+				'EventEspresso\core\domain\entities\route_match\RouteMatchSpecificationInterface',
82
+				// FQCNs for classes to add (all classes within each namespace will be loaded)
83
+				apply_filters(
84
+					'FHEE__EventEspresso_core_services_route_match_RouteMatchSpecificationManager__populateSpecificationCollection__collection_FQCNs',
85
+					array(
86
+						'EventEspresso\core\domain\entities\route_match\specifications\admin',
87
+						'EventEspresso\core\domain\entities\route_match\specifications\frontend',
88
+					)
89
+				),
90
+				// filepaths to classes to add
91
+				array(),
92
+				// file mask to use if parsing folder for files to add
93
+				'',
94
+				// what to use as identifier for collection entities
95
+				// using CLASS NAME prevents duplicates (works like a singleton)
96
+				CollectionDetails::ID_CLASS_NAME
97
+			),
98
+			$this->specifications,
99
+			null,
100
+			$this->specifications_factory
101
+		);
102
+		return $loader->getCollection();
103
+	}
104 104
 
105 105
 
106
-    /**
107
-     * Given the FQCN for a RouteMatchSpecification, will return true if the current request matches
108
-     *
109
-     * @param string $routeMatchSpecificationFqcn fully qualified class name
110
-     * @return bool
111
-     * @throws InvalidClassException
112
-     * @since 4.9.71.p
113
-     */
114
-    public function routeMatchesCurrentRequest($routeMatchSpecificationFqcn)
115
-    {
116
-        /** @var RouteMatchSpecificationInterface $specification */
117
-        $specification = $this->specifications->get($routeMatchSpecificationFqcn);
118
-        if (! $specification instanceof $routeMatchSpecificationFqcn) {
119
-            throw new InvalidClassException($routeMatchSpecificationFqcn);
120
-        }
121
-        return $specification->isMatchingRoute();
122
-    }
106
+	/**
107
+	 * Given the FQCN for a RouteMatchSpecification, will return true if the current request matches
108
+	 *
109
+	 * @param string $routeMatchSpecificationFqcn fully qualified class name
110
+	 * @return bool
111
+	 * @throws InvalidClassException
112
+	 * @since 4.9.71.p
113
+	 */
114
+	public function routeMatchesCurrentRequest($routeMatchSpecificationFqcn)
115
+	{
116
+		/** @var RouteMatchSpecificationInterface $specification */
117
+		$specification = $this->specifications->get($routeMatchSpecificationFqcn);
118
+		if (! $specification instanceof $routeMatchSpecificationFqcn) {
119
+			throw new InvalidClassException($routeMatchSpecificationFqcn);
120
+		}
121
+		return $specification->isMatchingRoute();
122
+	}
123 123
 
124 124
 
125
-    /**
126
-     * Handy method for development that returns
127
-     * a list of existing RouteMatchSpecification classes
128
-     * matching the current request that can be used to identify it.
129
-     * If no matches are returned (or nothing acceptable)
130
-     * then create a new one that better matches your requirements.
131
-     *
132
-     * @return array
133
-     * @since 4.9.71.p
134
-     */
135
-    public function findRouteMatchSpecificationsMatchingCurrentRequest()
136
-    {
137
-        $matches = array();
138
-        foreach ($this->specifications as $specification) {
139
-            /** @var RouteMatchSpecificationInterface $specification */
140
-            if ($specification->isMatchingRoute()) {
141
-                $matches[] = get_class($specification);
142
-            }
143
-        }
144
-        return $matches;
145
-    }
125
+	/**
126
+	 * Handy method for development that returns
127
+	 * a list of existing RouteMatchSpecification classes
128
+	 * matching the current request that can be used to identify it.
129
+	 * If no matches are returned (or nothing acceptable)
130
+	 * then create a new one that better matches your requirements.
131
+	 *
132
+	 * @return array
133
+	 * @since 4.9.71.p
134
+	 */
135
+	public function findRouteMatchSpecificationsMatchingCurrentRequest()
136
+	{
137
+		$matches = array();
138
+		foreach ($this->specifications as $specification) {
139
+			/** @var RouteMatchSpecificationInterface $specification */
140
+			if ($specification->isMatchingRoute()) {
141
+				$matches[] = get_class($specification);
142
+			}
143
+		}
144
+		return $matches;
145
+	}
146 146
 }
Please login to merge, or discard this patch.