@@ -203,12 +203,12 @@ |
||
| 203 | 203 | $sCode = match($sType) { |
| 204 | 204 | 'html' => jaxon()->package($sClass)?->getHtml() ?? '', |
| 205 | 205 | 'ready' => jaxon()->package($sClass)?->getReadyScript() ?? '', |
| 206 | - default => '' |
|
| 207 | - }; |
|
| 208 | - $sCode = trim($sCode); |
|
| 206 | +default => '' |
|
| 207 | +}; |
|
| 208 | +$sCode = trim($sCode); |
|
| 209 | 209 | |
| 210 | - return $sType !== 'ready' || $sCode === '' ? $sCode : |
|
| 211 | - // Call the ready code with the jaxon.dom.ready function. |
|
| 212 | - "jaxon.dom.ready(() => $sCode)"; |
|
| 213 | - } |
|
| 210 | +return $sType !== 'ready' || $sCode === '' ? $sCode : |
|
| 211 | +// Call the ready code with the jaxon.dom.ready function. |
|
| 212 | +"jaxon.dom.ready(() => $sCode)"; |
|
| 213 | +} |
|
| 214 | 214 | } |
@@ -9,35 +9,35 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | class Store implements JsonSerializable, Stringable |
| 11 | 11 | { |
| 12 | - /** |
|
| 12 | +/** |
|
| 13 | 13 | * The view renderer |
| 14 | 14 | * |
| 15 | 15 | * @var ViewInterface |
| 16 | 16 | */ |
| 17 | - protected $xRenderer; |
|
| 17 | +protected $xRenderer; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * The view namespace |
| 21 | 21 | * |
| 22 | 22 | * @var string |
| 23 | 23 | */ |
| 24 | - protected $sNamespace; |
|
| 24 | +protected $sNamespace; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 26 | +/** |
|
| 27 | 27 | * The view name |
| 28 | 28 | * |
| 29 | 29 | * @var string |
| 30 | 30 | */ |
| 31 | - protected $sViewName; |
|
| 31 | +protected $sViewName; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 33 | +/** |
|
| 34 | 34 | * The view data |
| 35 | 35 | * |
| 36 | 36 | * @var array |
| 37 | 37 | */ |
| 38 | - protected $aViewData = []; |
|
| 38 | +protected $aViewData = []; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 40 | +/** |
|
| 41 | 41 | * Make a piece of data available for the rendered view |
| 42 | 42 | * |
| 43 | 43 | * @param string $sName The data name |
@@ -45,26 +45,26 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @return Store |
| 47 | 47 | */ |
| 48 | - public function with(string $sName, $xValue): Store |
|
| 49 | - { |
|
| 50 | - $this->aViewData[$sName] = $xValue; |
|
| 51 | - return $this; |
|
| 52 | - } |
|
| 48 | +public function with(string $sName, $xValue): Store |
|
| 49 | +{ |
|
| 50 | +$this->aViewData[$sName] = $xValue; |
|
| 51 | +return $this; |
|
| 52 | +} |
|
| 53 | 53 | |
| 54 | - /** |
|
| 54 | +/** |
|
| 55 | 55 | * Set the data to be rendered |
| 56 | 56 | * |
| 57 | 57 | * @param array $aViewData The view data |
| 58 | 58 | * |
| 59 | 59 | * @return Store |
| 60 | 60 | */ |
| 61 | - public function setData(array $aViewData): Store |
|
| 62 | - { |
|
| 63 | - $this->aViewData = array_merge($this->aViewData, $aViewData); |
|
| 64 | - return $this; |
|
| 65 | - } |
|
| 61 | +public function setData(array $aViewData): Store |
|
| 62 | +{ |
|
| 63 | +$this->aViewData = array_merge($this->aViewData, $aViewData); |
|
| 64 | +return $this; |
|
| 65 | +} |
|
| 66 | 66 | |
| 67 | - /** |
|
| 67 | +/** |
|
| 68 | 68 | * Set the view to be rendered, with optional data |
| 69 | 69 | * |
| 70 | 70 | * @param ViewInterface $xRenderer The view renderer |
@@ -74,65 +74,65 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return Store |
| 76 | 76 | */ |
| 77 | - public function setView(ViewInterface $xRenderer, |
|
| 78 | - string $sNamespace, string $sViewName, array $aViewData = []): Store |
|
| 79 | - { |
|
| 80 | - $this->xRenderer = $xRenderer; |
|
| 81 | - $this->sNamespace = trim($sNamespace); |
|
| 82 | - $this->sViewName = trim($sViewName); |
|
| 83 | - $this->aViewData = array_merge($this->aViewData, $aViewData); |
|
| 84 | - return $this; |
|
| 85 | - } |
|
| 77 | +public function setView(ViewInterface $xRenderer, |
|
| 78 | +string $sNamespace, string $sViewName, array $aViewData = []): Store |
|
| 79 | +{ |
|
| 80 | +$this->xRenderer = $xRenderer; |
|
| 81 | +$this->sNamespace = trim($sNamespace); |
|
| 82 | +$this->sViewName = trim($sViewName); |
|
| 83 | +$this->aViewData = array_merge($this->aViewData, $aViewData); |
|
| 84 | +return $this; |
|
| 85 | +} |
|
| 86 | 86 | |
| 87 | - /** |
|
| 87 | +/** |
|
| 88 | 88 | * Get the view namespace |
| 89 | 89 | * |
| 90 | 90 | * @return string The view namespace |
| 91 | 91 | */ |
| 92 | - public function getNamespace(): string |
|
| 93 | - { |
|
| 94 | - return $this->sNamespace; |
|
| 95 | - } |
|
| 92 | +public function getNamespace(): string |
|
| 93 | +{ |
|
| 94 | +return $this->sNamespace; |
|
| 95 | +} |
|
| 96 | 96 | |
| 97 | - /** |
|
| 97 | +/** |
|
| 98 | 98 | * Get the view name |
| 99 | 99 | * |
| 100 | 100 | * @return string The view name |
| 101 | 101 | */ |
| 102 | - public function getViewName(): string |
|
| 103 | - { |
|
| 104 | - return $this->sViewName; |
|
| 105 | - } |
|
| 102 | +public function getViewName(): string |
|
| 103 | +{ |
|
| 104 | +return $this->sViewName; |
|
| 105 | +} |
|
| 106 | 106 | |
| 107 | - /** |
|
| 107 | +/** |
|
| 108 | 108 | * Get the view data |
| 109 | 109 | * |
| 110 | 110 | * @return array The view data |
| 111 | 111 | */ |
| 112 | - public function getViewData(): array |
|
| 113 | - { |
|
| 114 | - return $this->aViewData; |
|
| 115 | - } |
|
| 112 | +public function getViewData(): array |
|
| 113 | +{ |
|
| 114 | +return $this->aViewData; |
|
| 115 | +} |
|
| 116 | 116 | |
| 117 | - /** |
|
| 117 | +/** |
|
| 118 | 118 | * Render a view using third party view system |
| 119 | 119 | * |
| 120 | 120 | * @return string The string representation of the view |
| 121 | 121 | */ |
| 122 | - public function __toString(): string |
|
| 123 | - { |
|
| 124 | - return !$this->xRenderer ? '' : $this->xRenderer->render($this); |
|
| 125 | - } |
|
| 122 | +public function __toString(): string |
|
| 123 | +{ |
|
| 124 | +return !$this->xRenderer ? '' : $this->xRenderer->render($this); |
|
| 125 | +} |
|
| 126 | 126 | |
| 127 | - /** |
|
| 127 | +/** |
|
| 128 | 128 | * Convert this object to string for json. |
| 129 | 129 | * |
| 130 | 130 | * This is a method of the JsonSerializable interface. |
| 131 | 131 | * |
| 132 | 132 | * @return string |
| 133 | 133 | */ |
| 134 | - public function jsonSerialize(): string |
|
| 135 | - { |
|
| 136 | - return $this->__toString(); |
|
| 137 | - } |
|
| 134 | +public function jsonSerialize(): string |
|
| 135 | +{ |
|
| 136 | +return $this->__toString(); |
|
| 137 | +} |
|
| 138 | 138 | } |
@@ -11,110 +11,110 @@ |
||
| 11 | 11 | |
| 12 | 12 | class DataBag implements JsonSerializable |
| 13 | 13 | { |
| 14 | - /** |
|
| 14 | +/** |
|
| 15 | 15 | * @var DataBagPlugin |
| 16 | 16 | */ |
| 17 | - protected $xPlugin; |
|
| 17 | +protected $xPlugin; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * @var array |
| 21 | 21 | */ |
| 22 | - protected $aData = []; |
|
| 22 | +protected $aData = []; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * @var bool |
| 26 | 26 | */ |
| 27 | - protected $bTouched = false; |
|
| 27 | +protected $bTouched = false; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 29 | +/** |
|
| 30 | 30 | * The constructor |
| 31 | 31 | * |
| 32 | 32 | * @param array $aData |
| 33 | 33 | */ |
| 34 | - public function __construct(DataBagPlugin $xPlugin, array $aData) |
|
| 35 | - { |
|
| 36 | - $this->xPlugin = $xPlugin; |
|
| 37 | - // Ensure all contents are arrays. |
|
| 38 | - $this->aData = array_map(function($aValue) { |
|
| 39 | - return is_array($aValue) ? $aValue : []; |
|
| 40 | - }, $aData); |
|
| 41 | - } |
|
| 34 | +public function __construct(DataBagPlugin $xPlugin, array $aData) |
|
| 35 | +{ |
|
| 36 | +$this->xPlugin = $xPlugin; |
|
| 37 | +// Ensure all contents are arrays. |
|
| 38 | +$this->aData = array_map(function($aValue) { |
|
| 39 | +return is_array($aValue) ? $aValue : []; |
|
| 40 | +}, $aData); |
|
| 41 | +} |
|
| 42 | 42 | |
| 43 | - /** |
|
| 43 | +/** |
|
| 44 | 44 | * @return bool |
| 45 | 45 | */ |
| 46 | - public function touched(): bool |
|
| 47 | - { |
|
| 48 | - return $this->bTouched; |
|
| 49 | - } |
|
| 46 | +public function touched(): bool |
|
| 47 | +{ |
|
| 48 | +return $this->bTouched; |
|
| 49 | +} |
|
| 50 | 50 | |
| 51 | - /** |
|
| 51 | +/** |
|
| 52 | 52 | * @return array |
| 53 | 53 | */ |
| 54 | - public function getAll(): array |
|
| 55 | - { |
|
| 56 | - return $this->aData; |
|
| 57 | - } |
|
| 54 | +public function getAll(): array |
|
| 55 | +{ |
|
| 56 | +return $this->aData; |
|
| 57 | +} |
|
| 58 | 58 | |
| 59 | - /** |
|
| 59 | +/** |
|
| 60 | 60 | * @param string $sBag |
| 61 | 61 | * |
| 62 | 62 | * @return void |
| 63 | 63 | */ |
| 64 | - public function clear(string $sBag): void |
|
| 65 | - { |
|
| 66 | - $this->aData[$sBag] = []; |
|
| 67 | - $this->xPlugin->addCommand('databag.clear', ['bag' => $sBag]); |
|
| 68 | - } |
|
| 64 | +public function clear(string $sBag): void |
|
| 65 | +{ |
|
| 66 | +$this->aData[$sBag] = []; |
|
| 67 | +$this->xPlugin->addCommand('databag.clear', ['bag' => $sBag]); |
|
| 68 | +} |
|
| 69 | 69 | |
| 70 | - /** |
|
| 70 | +/** |
|
| 71 | 71 | * @param string $sBag |
| 72 | 72 | * @param string $sKey |
| 73 | 73 | * @param mixed $xValue |
| 74 | 74 | * |
| 75 | 75 | * @return void |
| 76 | 76 | */ |
| 77 | - public function set(string $sBag, string $sKey, $xValue): void |
|
| 78 | - { |
|
| 79 | - $this->bTouched = true; |
|
| 80 | - $this->aData[$sBag][$sKey] = $xValue; |
|
| 81 | - } |
|
| 77 | +public function set(string $sBag, string $sKey, $xValue): void |
|
| 78 | +{ |
|
| 79 | +$this->bTouched = true; |
|
| 80 | +$this->aData[$sBag][$sKey] = $xValue; |
|
| 81 | +} |
|
| 82 | 82 | |
| 83 | - /** |
|
| 83 | +/** |
|
| 84 | 84 | * @param string $sBag |
| 85 | 85 | * @param string $sKey |
| 86 | 86 | * @param mixed $xValue |
| 87 | 87 | * |
| 88 | 88 | * @return void |
| 89 | 89 | */ |
| 90 | - public function new(string $sBag, string $sKey, $xValue): void |
|
| 91 | - { |
|
| 92 | - // Set the value only if it doesn't already exist. |
|
| 93 | - if(!isset($this->aData[$sBag]) || !key_exists($sKey, $this->aData[$sBag])) |
|
| 94 | - { |
|
| 95 | - $this->set($sBag, $sKey, $xValue); |
|
| 96 | - } |
|
| 97 | - } |
|
| 90 | +public function new(string $sBag, string $sKey, $xValue): void |
|
| 91 | +{ |
|
| 92 | +// Set the value only if it doesn't already exist. |
|
| 93 | +if(!isset($this->aData[$sBag]) || !key_exists($sKey, $this->aData[$sBag])) |
|
| 94 | +{ |
|
| 95 | +$this->set($sBag, $sKey, $xValue); |
|
| 96 | +} |
|
| 97 | +} |
|
| 98 | 98 | |
| 99 | - /** |
|
| 99 | +/** |
|
| 100 | 100 | * @param string $sBag |
| 101 | 101 | * @param string $sKey |
| 102 | 102 | * @param mixed $xValue |
| 103 | 103 | * |
| 104 | 104 | * @return mixed |
| 105 | 105 | */ |
| 106 | - public function get(string $sBag, string $sKey, $xValue = null): mixed |
|
| 107 | - { |
|
| 108 | - return $this->aData[$sBag][$sKey] ?? $xValue; |
|
| 109 | - } |
|
| 106 | +public function get(string $sBag, string $sKey, $xValue = null): mixed |
|
| 107 | +{ |
|
| 108 | +return $this->aData[$sBag][$sKey] ?? $xValue; |
|
| 109 | +} |
|
| 110 | 110 | |
| 111 | - /** |
|
| 111 | +/** |
|
| 112 | 112 | * Convert this call to array, when converting the response into json. |
| 113 | 113 | * |
| 114 | 114 | * @return array |
| 115 | 115 | */ |
| 116 | - public function jsonSerialize(): array |
|
| 117 | - { |
|
| 118 | - return $this->aData; |
|
| 119 | - } |
|
| 116 | +public function jsonSerialize(): array |
|
| 117 | +{ |
|
| 118 | +return $this->aData; |
|
| 119 | +} |
|
| 120 | 120 | } |
@@ -4,58 +4,58 @@ |
||
| 4 | 4 | |
| 5 | 5 | class DataBagContext |
| 6 | 6 | { |
| 7 | - /** |
|
| 7 | +/** |
|
| 8 | 8 | * @var DataBag |
| 9 | 9 | */ |
| 10 | - protected $xDataBag; |
|
| 10 | +protected $xDataBag; |
|
| 11 | 11 | |
| 12 | - /** |
|
| 12 | +/** |
|
| 13 | 13 | * @var string |
| 14 | 14 | */ |
| 15 | - protected $sName; |
|
| 15 | +protected $sName; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | +/** |
|
| 18 | 18 | * The constructor |
| 19 | 19 | * |
| 20 | 20 | * @param DataBag $xDataBag |
| 21 | 21 | * @param string $sName |
| 22 | 22 | */ |
| 23 | - public function __construct(DataBag $xDataBag, string $sName) |
|
| 24 | - { |
|
| 25 | - $this->xDataBag = $xDataBag; |
|
| 26 | - $this->sName = $sName; |
|
| 27 | - } |
|
| 23 | +public function __construct(DataBag $xDataBag, string $sName) |
|
| 24 | +{ |
|
| 25 | +$this->xDataBag = $xDataBag; |
|
| 26 | +$this->sName = $sName; |
|
| 27 | +} |
|
| 28 | 28 | |
| 29 | - /** |
|
| 29 | +/** |
|
| 30 | 30 | * @param string $sKey |
| 31 | 31 | * @param mixed $xValue |
| 32 | 32 | * |
| 33 | 33 | * @return void |
| 34 | 34 | */ |
| 35 | - public function set(string $sKey, $xValue): void |
|
| 36 | - { |
|
| 37 | - $this->xDataBag->set($this->sName, $sKey, $xValue); |
|
| 38 | - } |
|
| 35 | +public function set(string $sKey, $xValue): void |
|
| 36 | +{ |
|
| 37 | +$this->xDataBag->set($this->sName, $sKey, $xValue); |
|
| 38 | +} |
|
| 39 | 39 | |
| 40 | - /** |
|
| 40 | +/** |
|
| 41 | 41 | * @param string $sKey |
| 42 | 42 | * @param mixed $xValue |
| 43 | 43 | * |
| 44 | 44 | * @return void |
| 45 | 45 | */ |
| 46 | - public function new(string $sKey, $xValue): void |
|
| 47 | - { |
|
| 48 | - $this->xDataBag->new($this->sName, $sKey, $xValue); |
|
| 49 | - } |
|
| 46 | +public function new(string $sKey, $xValue): void |
|
| 47 | +{ |
|
| 48 | +$this->xDataBag->new($this->sName, $sKey, $xValue); |
|
| 49 | +} |
|
| 50 | 50 | |
| 51 | - /** |
|
| 51 | +/** |
|
| 52 | 52 | * @param string $sKey |
| 53 | 53 | * @param mixed $xValue |
| 54 | 54 | * |
| 55 | 55 | * @return mixed |
| 56 | 56 | */ |
| 57 | - public function get(string $sKey, $xValue = null): mixed |
|
| 58 | - { |
|
| 59 | - return $this->xDataBag->get($this->sName, $sKey, $xValue); |
|
| 60 | - } |
|
| 57 | +public function get(string $sKey, $xValue = null): mixed |
|
| 58 | +{ |
|
| 59 | +return $this->xDataBag->get($this->sName, $sKey, $xValue); |
|
| 60 | +} |
|
| 61 | 61 | } |
@@ -16,23 +16,23 @@ |
||
| 16 | 16 | |
| 17 | 17 | class Jaxon |
| 18 | 18 | { |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * @const string |
| 21 | 21 | */ |
| 22 | - const VERSION = 'Jaxon 5.x'; |
|
| 22 | +const VERSION = 'Jaxon 5.x'; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * @const string |
| 26 | 26 | */ |
| 27 | - const CALLABLE_CLASS = 'CallableClass'; |
|
| 27 | +const CALLABLE_CLASS = 'CallableClass'; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 29 | +/** |
|
| 30 | 30 | * @const string |
| 31 | 31 | */ |
| 32 | - const CALLABLE_DIR = 'CallableDir'; |
|
| 32 | +const CALLABLE_DIR = 'CallableDir'; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 34 | +/** |
|
| 35 | 35 | * @const string |
| 36 | 36 | */ |
| 37 | - const CALLABLE_FUNCTION = 'CallableFunction'; |
|
| 37 | +const CALLABLE_FUNCTION = 'CallableFunction'; |
|
| 38 | 38 | } |
@@ -21,5 +21,5 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | function jaxon(): Jaxon |
| 23 | 23 | { |
| 24 | - return Jaxon::getInstance(); |
|
| 24 | +return Jaxon::getInstance(); |
|
| 25 | 25 | } |
@@ -15,56 +15,56 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | class Target implements TargetInterface |
| 17 | 17 | { |
| 18 | - /** |
|
| 18 | +/** |
|
| 19 | 19 | * The target type for function. |
| 20 | 20 | * |
| 21 | 21 | * @var string |
| 22 | 22 | */ |
| 23 | - const TYPE_FUNCTION = 'TargetFunction'; |
|
| 23 | +const TYPE_FUNCTION = 'TargetFunction'; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 25 | +/** |
|
| 26 | 26 | * The target type for class. |
| 27 | 27 | * |
| 28 | 28 | * @var string |
| 29 | 29 | */ |
| 30 | - const TYPE_CLASS = 'TargetClass'; |
|
| 30 | +const TYPE_CLASS = 'TargetClass'; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 32 | +/** |
|
| 33 | 33 | * The target type. |
| 34 | 34 | * |
| 35 | 35 | * @var string |
| 36 | 36 | */ |
| 37 | - private $sType = ''; |
|
| 37 | +private $sType = ''; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 39 | +/** |
|
| 40 | 40 | * The target function name. |
| 41 | 41 | * |
| 42 | 42 | * @var string |
| 43 | 43 | */ |
| 44 | - private $sFunctionName = ''; |
|
| 44 | +private $sFunctionName = ''; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 46 | +/** |
|
| 47 | 47 | * The target class name. |
| 48 | 48 | * |
| 49 | 49 | * @var string |
| 50 | 50 | */ |
| 51 | - private $sClassName = ''; |
|
| 51 | +private $sClassName = ''; |
|
| 52 | 52 | |
| 53 | - /** |
|
| 53 | +/** |
|
| 54 | 54 | * The target method name. |
| 55 | 55 | * |
| 56 | 56 | * @var string |
| 57 | 57 | */ |
| 58 | - private $sMethodName = ''; |
|
| 58 | +private $sMethodName = ''; |
|
| 59 | 59 | |
| 60 | - /** |
|
| 60 | +/** |
|
| 61 | 61 | * The target method args. |
| 62 | 62 | * |
| 63 | 63 | * @var array |
| 64 | 64 | */ |
| 65 | - private $aMethodArgs = []; |
|
| 65 | +private $aMethodArgs = []; |
|
| 66 | 66 | |
| 67 | - /** |
|
| 67 | +/** |
|
| 68 | 68 | * The constructor |
| 69 | 69 | * |
| 70 | 70 | * @param string $sType The target type |
@@ -73,28 +73,28 @@ discard block |
||
| 73 | 73 | * @param string $sMethodName The method name |
| 74 | 74 | * @param array $aMethodArgs The method args |
| 75 | 75 | */ |
| 76 | - private function __construct(string $sType, string $sFunctionName, string $sClassName, string $sMethodName, array $aMethodArgs = []) |
|
| 77 | - { |
|
| 78 | - $this->sType = $sType; |
|
| 79 | - $this->sFunctionName = $sFunctionName; |
|
| 80 | - $this->sClassName = $sClassName; |
|
| 81 | - $this->sMethodName = $sMethodName; |
|
| 82 | - $this->aMethodArgs = $aMethodArgs; |
|
| 83 | - } |
|
| 76 | +private function __construct(string $sType, string $sFunctionName, string $sClassName, string $sMethodName, array $aMethodArgs = []) |
|
| 77 | +{ |
|
| 78 | +$this->sType = $sType; |
|
| 79 | +$this->sFunctionName = $sFunctionName; |
|
| 80 | +$this->sClassName = $sClassName; |
|
| 81 | +$this->sMethodName = $sMethodName; |
|
| 82 | +$this->aMethodArgs = $aMethodArgs; |
|
| 83 | +} |
|
| 84 | 84 | |
| 85 | - /** |
|
| 85 | +/** |
|
| 86 | 86 | * Create a target of type Function |
| 87 | 87 | * |
| 88 | 88 | * @param string $sFunctionName The function name |
| 89 | 89 | * |
| 90 | 90 | * @return Target |
| 91 | 91 | */ |
| 92 | - public static function makeFunction(string $sFunctionName): Target |
|
| 93 | - { |
|
| 94 | - return new Target(self::TYPE_FUNCTION, $sFunctionName, '', ''); |
|
| 95 | - } |
|
| 92 | +public static function makeFunction(string $sFunctionName): Target |
|
| 93 | +{ |
|
| 94 | +return new Target(self::TYPE_FUNCTION, $sFunctionName, '', ''); |
|
| 95 | +} |
|
| 96 | 96 | |
| 97 | - /** |
|
| 97 | +/** |
|
| 98 | 98 | * Create a target of type Class |
| 99 | 99 | * |
| 100 | 100 | * @param string $sClassName The class name |
@@ -102,88 +102,88 @@ discard block |
||
| 102 | 102 | * |
| 103 | 103 | * @return Target |
| 104 | 104 | */ |
| 105 | - public static function makeClass(string $sClassName, string $sMethodName): Target |
|
| 106 | - { |
|
| 107 | - return new Target(self::TYPE_CLASS, '', $sClassName, $sMethodName); |
|
| 108 | - } |
|
| 105 | +public static function makeClass(string $sClassName, string $sMethodName): Target |
|
| 106 | +{ |
|
| 107 | +return new Target(self::TYPE_CLASS, '', $sClassName, $sMethodName); |
|
| 108 | +} |
|
| 109 | 109 | |
| 110 | - /** |
|
| 110 | +/** |
|
| 111 | 111 | * Check if the target type is Function. |
| 112 | 112 | * |
| 113 | 113 | * @return bool |
| 114 | 114 | */ |
| 115 | - public function isFunction(): bool |
|
| 116 | - { |
|
| 117 | - return $this->sType === self::TYPE_FUNCTION; |
|
| 118 | - } |
|
| 115 | +public function isFunction(): bool |
|
| 116 | +{ |
|
| 117 | +return $this->sType === self::TYPE_FUNCTION; |
|
| 118 | +} |
|
| 119 | 119 | |
| 120 | - /** |
|
| 120 | +/** |
|
| 121 | 121 | * Check if the target type is Class. |
| 122 | 122 | * |
| 123 | 123 | * @return bool |
| 124 | 124 | */ |
| 125 | - public function isClass(): bool |
|
| 126 | - { |
|
| 127 | - return $this->sType === self::TYPE_CLASS; |
|
| 128 | - } |
|
| 125 | +public function isClass(): bool |
|
| 126 | +{ |
|
| 127 | +return $this->sType === self::TYPE_CLASS; |
|
| 128 | +} |
|
| 129 | 129 | |
| 130 | - /** |
|
| 130 | +/** |
|
| 131 | 131 | * The target function name. |
| 132 | 132 | * |
| 133 | 133 | * @return string |
| 134 | 134 | */ |
| 135 | - public function getFunctionName(): string |
|
| 136 | - { |
|
| 137 | - return $this->sFunctionName; |
|
| 138 | - } |
|
| 135 | +public function getFunctionName(): string |
|
| 136 | +{ |
|
| 137 | +return $this->sFunctionName; |
|
| 138 | +} |
|
| 139 | 139 | |
| 140 | - /** |
|
| 140 | +/** |
|
| 141 | 141 | * The target class name. |
| 142 | 142 | * |
| 143 | 143 | * @return string |
| 144 | 144 | */ |
| 145 | - public function getClassName(): string |
|
| 146 | - { |
|
| 147 | - return $this->sClassName; |
|
| 148 | - } |
|
| 145 | +public function getClassName(): string |
|
| 146 | +{ |
|
| 147 | +return $this->sClassName; |
|
| 148 | +} |
|
| 149 | 149 | |
| 150 | - /** |
|
| 150 | +/** |
|
| 151 | 151 | * The target method name. |
| 152 | 152 | * |
| 153 | 153 | * @return string |
| 154 | 154 | */ |
| 155 | - public function getMethodName(): string |
|
| 156 | - { |
|
| 157 | - return $this->sMethodName; |
|
| 158 | - } |
|
| 155 | +public function getMethodName(): string |
|
| 156 | +{ |
|
| 157 | +return $this->sMethodName; |
|
| 158 | +} |
|
| 159 | 159 | |
| 160 | - /** |
|
| 160 | +/** |
|
| 161 | 161 | * Set the target method name. |
| 162 | 162 | * |
| 163 | 163 | * @param array $aMethodArgs |
| 164 | 164 | */ |
| 165 | - public function setMethodArgs(array $aMethodArgs): void |
|
| 166 | - { |
|
| 167 | - $this->aMethodArgs = $aMethodArgs; |
|
| 168 | - } |
|
| 165 | +public function setMethodArgs(array $aMethodArgs): void |
|
| 166 | +{ |
|
| 167 | +$this->aMethodArgs = $aMethodArgs; |
|
| 168 | +} |
|
| 169 | 169 | |
| 170 | - /** |
|
| 170 | +/** |
|
| 171 | 171 | * The target method name. |
| 172 | 172 | * |
| 173 | 173 | * @return string |
| 174 | 174 | */ |
| 175 | - public function method(): string |
|
| 176 | - { |
|
| 177 | - return $this->sMethodName; |
|
| 178 | - } |
|
| 175 | +public function method(): string |
|
| 176 | +{ |
|
| 177 | +return $this->sMethodName; |
|
| 178 | +} |
|
| 179 | 179 | |
| 180 | - /** |
|
| 180 | +/** |
|
| 181 | 181 | * The target method args. |
| 182 | 182 | * |
| 183 | 183 | * @return array |
| 184 | 184 | */ |
| 185 | - public function args(): array |
|
| 186 | - { |
|
| 187 | - return $this->aMethodArgs; |
|
| 188 | - } |
|
| 185 | +public function args(): array |
|
| 186 | +{ |
|
| 187 | +return $this->aMethodArgs; |
|
| 188 | +} |
|
| 189 | 189 | } |
@@ -4,17 +4,17 @@ |
||
| 4 | 4 | |
| 5 | 5 | interface TargetInterface |
| 6 | 6 | { |
| 7 | - /** |
|
| 7 | +/** |
|
| 8 | 8 | * The target method name. |
| 9 | 9 | * |
| 10 | 10 | * @return string |
| 11 | 11 | */ |
| 12 | - public function method(): string; |
|
| 12 | +public function method(): string; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 14 | +/** |
|
| 15 | 15 | * The target method args. |
| 16 | 16 | * |
| 17 | 17 | * @return array |
| 18 | 18 | */ |
| 19 | - public function args(): array; |
|
| 19 | +public function args(): array; |
|
| 20 | 20 | } |
@@ -29,73 +29,73 @@ |
||
| 29 | 29 | |
| 30 | 30 | class Validator |
| 31 | 31 | { |
| 32 | - /** |
|
| 32 | +/** |
|
| 33 | 33 | * The config manager |
| 34 | 34 | * |
| 35 | 35 | * @var ConfigManager |
| 36 | 36 | */ |
| 37 | - protected $xConfigManager; |
|
| 37 | +protected $xConfigManager; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 39 | +/** |
|
| 40 | 40 | * The translator |
| 41 | 41 | * |
| 42 | 42 | * @var Translator |
| 43 | 43 | */ |
| 44 | - protected $xTranslator; |
|
| 44 | +protected $xTranslator; |
|
| 45 | 45 | |
| 46 | - public function __construct(ConfigManager $xConfigManager, Translator $xTranslator) |
|
| 47 | - { |
|
| 48 | - // Set the config manager |
|
| 49 | - $this->xConfigManager = $xConfigManager; |
|
| 50 | - // Set the translator |
|
| 51 | - $this->xTranslator = $xTranslator; |
|
| 52 | - } |
|
| 46 | +public function __construct(ConfigManager $xConfigManager, Translator $xTranslator) |
|
| 47 | +{ |
|
| 48 | +// Set the config manager |
|
| 49 | +$this->xConfigManager = $xConfigManager; |
|
| 50 | +// Set the translator |
|
| 51 | +$this->xTranslator = $xTranslator; |
|
| 52 | +} |
|
| 53 | 53 | |
| 54 | - /** |
|
| 54 | +/** |
|
| 55 | 55 | * Validate a function name |
| 56 | 56 | * |
| 57 | 57 | * @param string $sName The function name |
| 58 | 58 | * |
| 59 | 59 | * @return bool |
| 60 | 60 | */ |
| 61 | - public function validateFunction(string $sName): bool |
|
| 62 | - { |
|
| 63 | - return preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $sName) > 0; |
|
| 64 | - } |
|
| 61 | +public function validateFunction(string $sName): bool |
|
| 62 | +{ |
|
| 63 | +return preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $sName) > 0; |
|
| 64 | +} |
|
| 65 | 65 | |
| 66 | - /** |
|
| 66 | +/** |
|
| 67 | 67 | * Validate a class name |
| 68 | 68 | * |
| 69 | 69 | * @param string $sName The class name |
| 70 | 70 | * |
| 71 | 71 | * @return bool |
| 72 | 72 | */ |
| 73 | - public function validateJsObject(string $sName): bool |
|
| 74 | - { |
|
| 75 | - return preg_match('/^([a-zA-Z][a-zA-Z0-9_]*)(\.[a-zA-Z][a-zA-Z0-9_]*)*$/', $sName) > 0; |
|
| 76 | - } |
|
| 73 | +public function validateJsObject(string $sName): bool |
|
| 74 | +{ |
|
| 75 | +return preg_match('/^([a-zA-Z][a-zA-Z0-9_]*)(\.[a-zA-Z][a-zA-Z0-9_]*)*$/', $sName) > 0; |
|
| 76 | +} |
|
| 77 | 77 | |
| 78 | - /** |
|
| 78 | +/** |
|
| 79 | 79 | * Validate a class name |
| 80 | 80 | * |
| 81 | 81 | * @param string $sName The class name |
| 82 | 82 | * |
| 83 | 83 | * @return bool |
| 84 | 84 | */ |
| 85 | - public function validateClass(string $sName): bool |
|
| 86 | - { |
|
| 87 | - return preg_match('/^([a-zA-Z][a-zA-Z0-9_]*)(\\\\[a-zA-Z][a-zA-Z0-9_]*)*$/', $sName) > 0; |
|
| 88 | - } |
|
| 85 | +public function validateClass(string $sName): bool |
|
| 86 | +{ |
|
| 87 | +return preg_match('/^([a-zA-Z][a-zA-Z0-9_]*)(\\\\[a-zA-Z][a-zA-Z0-9_]*)*$/', $sName) > 0; |
|
| 88 | +} |
|
| 89 | 89 | |
| 90 | - /** |
|
| 90 | +/** |
|
| 91 | 91 | * Validate a method name |
| 92 | 92 | * |
| 93 | 93 | * @param string $sName The function name |
| 94 | 94 | * |
| 95 | 95 | * @return bool |
| 96 | 96 | */ |
| 97 | - public function validateMethod(string $sName): bool |
|
| 98 | - { |
|
| 99 | - return preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $sName) > 0; |
|
| 100 | - } |
|
| 97 | +public function validateMethod(string $sName): bool |
|
| 98 | +{ |
|
| 99 | +return preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $sName) > 0; |
|
| 100 | +} |
|
| 101 | 101 | } |