PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.0.4
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.0.4
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
acymailing / back / Core / AcymParameter.php

AcymParameter.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 11.0.4, at back/Core/AcymParameter.php

48 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AcyMailing\Core;
4
5 class AcymParameter
6 {
7 private array $params = [];
8 private object $paramObject;
9
10 /**
11 * @param null $params We expect a json encoded object, but it could directly be an object with protected data in Joomla 3
12 */
13 public function __construct($params = null)
14 {
15 if (is_string($params)) {
16 $this->params = json_decode($params, true);
17 } elseif (is_array($params)) {
18 $this->params = $params;
19 } elseif (is_object($params)) {
20 $this->paramObject = $params;
21 }
22 }
23
24 /**
25 * @param mixed $default
26 *
27 * @return mixed
28 */
29 public function get(string $path, $default = null)
30 {
31 if (empty($this->paramObject)) {
32 if (empty($this->params[$path]) && !(isset($this->params[$path]) && $this->params[$path] === '0')) {
33 return $default;
34 }
35
36 return $this->params[$path];
37 } else {
38 // Handle the object based parameters
39 $value = $this->paramObject->get($path, 'noval');
40 if ($value === 'noval') {
41 $value = $this->paramObject->get('data.'.$path, $default);
42 }
43
44 return $value;
45 }
46 }
47 }
48