@@ -16,49 +16,49 @@ |
||
| 16 | 16 | |
| 17 | 17 | class HtmlValue extends TypedValue |
| 18 | 18 | { |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * The class contructor |
| 21 | 21 | * |
| 22 | 22 | * @param array $aValue |
| 23 | 23 | */ |
| 24 | - public function __construct(protected array $aValue) |
|
| 25 | - {} |
|
| 24 | +public function __construct(protected array $aValue) |
|
| 25 | +{} |
|
| 26 | 26 | |
| 27 | - /** |
|
| 27 | +/** |
|
| 28 | 28 | * @inheritDoc |
| 29 | 29 | */ |
| 30 | - public function getType(): string |
|
| 31 | - { |
|
| 32 | - return $this->aValue['_type'] ?? '_'; |
|
| 33 | - } |
|
| 30 | +public function getType(): string |
|
| 31 | +{ |
|
| 32 | +return $this->aValue['_type'] ?? '_'; |
|
| 33 | +} |
|
| 34 | 34 | |
| 35 | - /** |
|
| 35 | +/** |
|
| 36 | 36 | * Convert the js value to int |
| 37 | 37 | * |
| 38 | 38 | * @return self |
| 39 | 39 | */ |
| 40 | - public function toInt(): self |
|
| 41 | - { |
|
| 42 | - $this->aValue['toInt'] = true; |
|
| 43 | - return $this; |
|
| 44 | - } |
|
| 40 | +public function toInt(): self |
|
| 41 | +{ |
|
| 42 | +$this->aValue['toInt'] = true; |
|
| 43 | +return $this; |
|
| 44 | +} |
|
| 45 | 45 | |
| 46 | - /** |
|
| 46 | +/** |
|
| 47 | 47 | * Trim the js value |
| 48 | 48 | * |
| 49 | 49 | * @return self |
| 50 | 50 | */ |
| 51 | - public function trim(): self |
|
| 52 | - { |
|
| 53 | - $this->aValue['trim'] = true; |
|
| 54 | - return $this; |
|
| 55 | - } |
|
| 51 | +public function trim(): self |
|
| 52 | +{ |
|
| 53 | +$this->aValue['trim'] = true; |
|
| 54 | +return $this; |
|
| 55 | +} |
|
| 56 | 56 | |
| 57 | - /** |
|
| 57 | +/** |
|
| 58 | 58 | * @return array |
| 59 | 59 | */ |
| 60 | - public function jsonSerialize(): array |
|
| 61 | - { |
|
| 62 | - return $this->aValue; |
|
| 63 | - } |
|
| 60 | +public function jsonSerialize(): array |
|
| 61 | +{ |
|
| 62 | +return $this->aValue; |
|
| 63 | +} |
|
| 64 | 64 | } |
@@ -7,29 +7,29 @@ |
||
| 7 | 7 | |
| 8 | 8 | class Event implements JsonSerializable |
| 9 | 9 | { |
| 10 | - /** |
|
| 10 | +/** |
|
| 11 | 11 | * The constructor. |
| 12 | 12 | * |
| 13 | 13 | * @param string $sMode The event mode: 'jq' or 'js' |
| 14 | 14 | * @param string $sName The event name |
| 15 | 15 | * @param JsExpr $xHandler The event handler |
| 16 | 16 | */ |
| 17 | - public function __construct(private string $sMode, |
|
| 18 | - private string $sName, private JsExpr $xHandler) |
|
| 19 | - {} |
|
| 17 | +public function __construct(private string $sMode, |
|
| 18 | +private string $sName, private JsExpr $xHandler) |
|
| 19 | +{} |
|
| 20 | 20 | |
| 21 | - /** |
|
| 21 | +/** |
|
| 22 | 22 | * Convert this call to array, when converting the response into json. |
| 23 | 23 | * |
| 24 | 24 | * @return array |
| 25 | 25 | */ |
| 26 | - public function jsonSerialize(): array |
|
| 27 | - { |
|
| 28 | - return [ |
|
| 29 | - '_type' => 'event', |
|
| 30 | - '_name' => $this->sName, |
|
| 31 | - 'mode' => $this->sMode, |
|
| 32 | - 'func' => $this->xHandler->jsonSerialize(), |
|
| 33 | - ]; |
|
| 34 | - } |
|
| 26 | +public function jsonSerialize(): array |
|
| 27 | +{ |
|
| 28 | +return [ |
|
| 29 | +'_type' => 'event', |
|
| 30 | +'_name' => $this->sName, |
|
| 31 | +'mode' => $this->sMode, |
|
| 32 | +'func' => $this->xHandler->jsonSerialize(), |
|
| 33 | +]; |
|
| 34 | +} |
|
| 35 | 35 | } |
@@ -15,25 +15,25 @@ |
||
| 15 | 15 | |
| 16 | 16 | class SimpleValue extends TypedValue |
| 17 | 17 | { |
| 18 | - /** |
|
| 18 | +/** |
|
| 19 | 19 | * @param mixed $xValue |
| 20 | 20 | */ |
| 21 | - public function __construct(private mixed $xValue) |
|
| 22 | - {} |
|
| 21 | +public function __construct(private mixed $xValue) |
|
| 22 | +{} |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * @inheritDoc |
| 26 | 26 | */ |
| 27 | - public function getType(): string |
|
| 28 | - { |
|
| 29 | - return '_'; |
|
| 30 | - } |
|
| 27 | +public function getType(): string |
|
| 28 | +{ |
|
| 29 | +return '_'; |
|
| 30 | +} |
|
| 31 | 31 | |
| 32 | - /** |
|
| 32 | +/** |
|
| 33 | 33 | * @return mixed |
| 34 | 34 | */ |
| 35 | - public function jsonSerialize(): mixed |
|
| 36 | - { |
|
| 37 | - return $this->xValue; |
|
| 38 | - } |
|
| 35 | +public function jsonSerialize(): mixed |
|
| 36 | +{ |
|
| 37 | +return $this->xValue; |
|
| 38 | +} |
|
| 39 | 39 | } |
@@ -15,19 +15,19 @@ |
||
| 15 | 15 | |
| 16 | 16 | class PageValue extends TypedValue |
| 17 | 17 | { |
| 18 | - /** |
|
| 18 | +/** |
|
| 19 | 19 | * @return string |
| 20 | 20 | */ |
| 21 | - public function getType(): string |
|
| 22 | - { |
|
| 23 | - return 'page'; |
|
| 24 | - } |
|
| 21 | +public function getType(): string |
|
| 22 | +{ |
|
| 23 | +return 'page'; |
|
| 24 | +} |
|
| 25 | 25 | |
| 26 | - /** |
|
| 26 | +/** |
|
| 27 | 27 | * @return array |
| 28 | 28 | */ |
| 29 | - public function jsonSerialize(): array |
|
| 30 | - { |
|
| 31 | - return ['_type' => 'page', '_name' => '']; |
|
| 32 | - } |
|
| 29 | +public function jsonSerialize(): array |
|
| 30 | +{ |
|
| 31 | +return ['_type' => 'page', '_name' => '']; |
|
| 32 | +} |
|
| 33 | 33 | } |
@@ -7,53 +7,53 @@ |
||
| 7 | 7 | |
| 8 | 8 | class Func extends TypedValue |
| 9 | 9 | { |
| 10 | - /** |
|
| 10 | +/** |
|
| 11 | 11 | * The constructor. |
| 12 | 12 | * |
| 13 | 13 | * @param string $sName The method name |
| 14 | 14 | * @param array $aArguments The method arguments |
| 15 | 15 | */ |
| 16 | - public function __construct(private string $sName, private array $aArguments) |
|
| 17 | - {} |
|
| 16 | +public function __construct(private string $sName, private array $aArguments) |
|
| 17 | +{} |
|
| 18 | 18 | |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * @inheritDoc |
| 21 | 21 | */ |
| 22 | - public function getType(): string |
|
| 23 | - { |
|
| 24 | - return 'func'; |
|
| 25 | - } |
|
| 22 | +public function getType(): string |
|
| 23 | +{ |
|
| 24 | +return 'func'; |
|
| 25 | +} |
|
| 26 | 26 | |
| 27 | - /** |
|
| 27 | +/** |
|
| 28 | 28 | * Add the page number to the function arguments. |
| 29 | 29 | * |
| 30 | 30 | * @return self |
| 31 | 31 | */ |
| 32 | - public function withPage(): self |
|
| 33 | - { |
|
| 34 | - foreach($this->aArguments as $xArgument) |
|
| 35 | - { |
|
| 36 | - if(TypedValue::isPage($xArgument)) |
|
| 37 | - { |
|
| 38 | - return $this; |
|
| 39 | - } |
|
| 40 | - } |
|
| 41 | - $this->aArguments[] = TypedValue::page(); |
|
| 42 | - return $this; |
|
| 43 | - } |
|
| 32 | +public function withPage(): self |
|
| 33 | +{ |
|
| 34 | +foreach($this->aArguments as $xArgument) |
|
| 35 | +{ |
|
| 36 | +if(TypedValue::isPage($xArgument)) |
|
| 37 | +{ |
|
| 38 | + return $this; |
|
| 39 | +} |
|
| 40 | +} |
|
| 41 | +$this->aArguments[] = TypedValue::page(); |
|
| 42 | +return $this; |
|
| 43 | +} |
|
| 44 | 44 | |
| 45 | - /** |
|
| 45 | +/** |
|
| 46 | 46 | * Convert this call to array, when converting the response into json. |
| 47 | 47 | * |
| 48 | 48 | * @return array |
| 49 | 49 | */ |
| 50 | - public function jsonSerialize(): array |
|
| 51 | - { |
|
| 52 | - return [ |
|
| 53 | - '_type' => $this->getType(), |
|
| 54 | - '_name' => $this->sName, |
|
| 55 | - 'args' => array_map(fn(mixed $xArgument) => |
|
| 56 | - TypedValue::make($xArgument)->jsonSerialize(), $this->aArguments), |
|
| 57 | - ]; |
|
| 58 | - } |
|
| 50 | +public function jsonSerialize(): array |
|
| 51 | +{ |
|
| 52 | +return [ |
|
| 53 | +'_type' => $this->getType(), |
|
| 54 | +'_name' => $this->sName, |
|
| 55 | +'args' => array_map(fn(mixed $xArgument) => |
|
| 56 | + TypedValue::make($xArgument)->jsonSerialize(), $this->aArguments), |
|
| 57 | +]; |
|
| 58 | +} |
|
| 59 | 59 | } |
@@ -31,9 +31,9 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | public function withPage(): self |
| 33 | 33 | { |
| 34 | - foreach($this->aArguments as $xArgument) |
|
| 34 | + foreach ($this->aArguments as $xArgument) |
|
| 35 | 35 | { |
| 36 | - if(TypedValue::isPage($xArgument)) |
|
| 36 | + if (TypedValue::isPage($xArgument)) |
|
| 37 | 37 | { |
| 38 | 38 | return $this; |
| 39 | 39 | } |
@@ -4,38 +4,38 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | class Attr extends TypedValue |
| 6 | 6 | { |
| 7 | - /** |
|
| 7 | +/** |
|
| 8 | 8 | * The constructor |
| 9 | 9 | * |
| 10 | 10 | * @param array $aValue |
| 11 | 11 | */ |
| 12 | - public function __construct(private array $aValue) |
|
| 13 | - {} |
|
| 12 | +public function __construct(private array $aValue) |
|
| 13 | +{} |
|
| 14 | 14 | |
| 15 | - /** |
|
| 15 | +/** |
|
| 16 | 16 | * @inheritDoc |
| 17 | 17 | */ |
| 18 | - public function getType(): string |
|
| 19 | - { |
|
| 20 | - return $this->aValue['_type'] ?? '_'; |
|
| 21 | - } |
|
| 18 | +public function getType(): string |
|
| 19 | +{ |
|
| 20 | +return $this->aValue['_type'] ?? '_'; |
|
| 21 | +} |
|
| 22 | 22 | |
| 23 | - /** |
|
| 23 | +/** |
|
| 24 | 24 | * Create an abject to get the value of an attribute |
| 25 | 25 | * |
| 26 | 26 | * @param string $sAttrName The attribute name |
| 27 | 27 | * |
| 28 | 28 | * @return Attr |
| 29 | 29 | */ |
| 30 | - public static function get(string $sAttrName): Attr |
|
| 31 | - { |
|
| 32 | - return new Attr([ |
|
| 33 | - '_type' => 'attr', |
|
| 34 | - '_name' => $sAttrName, |
|
| 35 | - ]); |
|
| 36 | - } |
|
| 30 | +public static function get(string $sAttrName): Attr |
|
| 31 | +{ |
|
| 32 | +return new Attr([ |
|
| 33 | +'_type' => 'attr', |
|
| 34 | +'_name' => $sAttrName, |
|
| 35 | +]); |
|
| 36 | +} |
|
| 37 | 37 | |
| 38 | - /** |
|
| 38 | +/** |
|
| 39 | 39 | * Create an abject to set the value of an attribute |
| 40 | 40 | * |
| 41 | 41 | * @param string $sAttrName The attribute name |
@@ -43,22 +43,22 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @return Attr |
| 45 | 45 | */ |
| 46 | - public static function set(string $sAttrName, $xAttrValue): Attr |
|
| 47 | - { |
|
| 48 | - return new Attr([ |
|
| 49 | - '_type' => 'attr', |
|
| 50 | - '_name' => $sAttrName, |
|
| 51 | - 'value' => TypedValue::make($xAttrValue)->jsonSerialize(), |
|
| 52 | - ]); |
|
| 53 | - } |
|
| 46 | +public static function set(string $sAttrName, $xAttrValue): Attr |
|
| 47 | +{ |
|
| 48 | +return new Attr([ |
|
| 49 | +'_type' => 'attr', |
|
| 50 | +'_name' => $sAttrName, |
|
| 51 | +'value' => TypedValue::make($xAttrValue)->jsonSerialize(), |
|
| 52 | +]); |
|
| 53 | +} |
|
| 54 | 54 | |
| 55 | - /** |
|
| 55 | +/** |
|
| 56 | 56 | * Convert this call to array, when converting the response into json. |
| 57 | 57 | * |
| 58 | 58 | * @return array |
| 59 | 59 | */ |
| 60 | - public function jsonSerialize(): array |
|
| 61 | - { |
|
| 62 | - return $this->aValue; |
|
| 63 | - } |
|
| 60 | +public function jsonSerialize(): array |
|
| 61 | +{ |
|
| 62 | +return $this->aValue; |
|
| 63 | +} |
|
| 64 | 64 | } |
@@ -19,36 +19,36 @@ |
||
| 19 | 19 | |
| 20 | 20 | abstract class TypedValue implements JsonSerializable |
| 21 | 21 | { |
| 22 | - /** |
|
| 22 | +/** |
|
| 23 | 23 | * @return string |
| 24 | 24 | */ |
| 25 | - abstract public function getType(): string; |
|
| 25 | +abstract public function getType(): string; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 27 | +/** |
|
| 28 | 28 | * @param mixed $xValue |
| 29 | 29 | * |
| 30 | 30 | * @return TypedValue |
| 31 | 31 | */ |
| 32 | - public static function make(mixed $xValue): TypedValue |
|
| 33 | - { |
|
| 34 | - return $xValue instanceof TypedValue ? $xValue : new SimpleValue($xValue); |
|
| 35 | - } |
|
| 32 | +public static function make(mixed $xValue): TypedValue |
|
| 33 | +{ |
|
| 34 | +return $xValue instanceof TypedValue ? $xValue : new SimpleValue($xValue); |
|
| 35 | +} |
|
| 36 | 36 | |
| 37 | - /** |
|
| 37 | +/** |
|
| 38 | 38 | * @return PageValue |
| 39 | 39 | */ |
| 40 | - public static function page(): PageValue |
|
| 41 | - { |
|
| 42 | - return new PageValue(); |
|
| 43 | - } |
|
| 40 | +public static function page(): PageValue |
|
| 41 | +{ |
|
| 42 | +return new PageValue(); |
|
| 43 | +} |
|
| 44 | 44 | |
| 45 | - /** |
|
| 45 | +/** |
|
| 46 | 46 | * @param mixed $xValue |
| 47 | 47 | * |
| 48 | 48 | * @return bool |
| 49 | 49 | */ |
| 50 | - public static function isPage(mixed $xValue): bool |
|
| 51 | - { |
|
| 52 | - return is_a($xValue, PageValue::class); |
|
| 53 | - } |
|
| 50 | +public static function isPage(mixed $xValue): bool |
|
| 51 | +{ |
|
| 52 | +return is_a($xValue, PageValue::class); |
|
| 53 | +} |
|
| 54 | 54 | } |
@@ -16,59 +16,59 @@ |
||
| 16 | 16 | |
| 17 | 17 | class HtmlReader |
| 18 | 18 | { |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * The class constructor |
| 21 | 21 | * |
| 22 | 22 | * @param string $sElementId |
| 23 | 23 | */ |
| 24 | - public function __construct(private string $sElementId = '') |
|
| 25 | - {} |
|
| 24 | +public function __construct(private string $sElementId = '') |
|
| 25 | +{} |
|
| 26 | 26 | |
| 27 | - /** |
|
| 27 | +/** |
|
| 28 | 28 | * @return array |
| 29 | 29 | */ |
| 30 | - public function form(): array |
|
| 31 | - { |
|
| 32 | - return ['_type' => 'form', '_name' => $this->sElementId]; |
|
| 33 | - } |
|
| 30 | +public function form(): array |
|
| 31 | +{ |
|
| 32 | +return ['_type' => 'form', '_name' => $this->sElementId]; |
|
| 33 | +} |
|
| 34 | 34 | |
| 35 | - /** |
|
| 35 | +/** |
|
| 36 | 36 | * @return array |
| 37 | 37 | */ |
| 38 | - public function checked(): array |
|
| 39 | - { |
|
| 40 | - return ['_type' => 'checked', '_name' => $this->sElementId]; |
|
| 41 | - } |
|
| 38 | +public function checked(): array |
|
| 39 | +{ |
|
| 40 | +return ['_type' => 'checked', '_name' => $this->sElementId]; |
|
| 41 | +} |
|
| 42 | 42 | |
| 43 | - /** |
|
| 43 | +/** |
|
| 44 | 44 | * @return HtmlValue |
| 45 | 45 | */ |
| 46 | - public function input(): HtmlValue |
|
| 47 | - { |
|
| 48 | - return new HtmlValue(['_type' => 'input', '_name' => $this->sElementId]); |
|
| 49 | - } |
|
| 46 | +public function input(): HtmlValue |
|
| 47 | +{ |
|
| 48 | +return new HtmlValue(['_type' => 'input', '_name' => $this->sElementId]); |
|
| 49 | +} |
|
| 50 | 50 | |
| 51 | - /** |
|
| 51 | +/** |
|
| 52 | 52 | * @return HtmlValue |
| 53 | 53 | */ |
| 54 | - public function select(): HtmlValue |
|
| 55 | - { |
|
| 56 | - return $this->input(); |
|
| 57 | - } |
|
| 54 | +public function select(): HtmlValue |
|
| 55 | +{ |
|
| 56 | +return $this->input(); |
|
| 57 | +} |
|
| 58 | 58 | |
| 59 | - /** |
|
| 59 | +/** |
|
| 60 | 60 | * @return HtmlValue |
| 61 | 61 | */ |
| 62 | - public function html(): HtmlValue |
|
| 63 | - { |
|
| 64 | - return new HtmlValue(['_type' => 'html', '_name' => $this->sElementId]); |
|
| 65 | - } |
|
| 62 | +public function html(): HtmlValue |
|
| 63 | +{ |
|
| 64 | +return new HtmlValue(['_type' => 'html', '_name' => $this->sElementId]); |
|
| 65 | +} |
|
| 66 | 66 | |
| 67 | - /** |
|
| 67 | +/** |
|
| 68 | 68 | * @return PageValue |
| 69 | 69 | */ |
| 70 | - public function page(): PageValue |
|
| 71 | - { |
|
| 72 | - return TypedValue::page(); |
|
| 73 | - } |
|
| 70 | +public function page(): PageValue |
|
| 71 | +{ |
|
| 72 | +return TypedValue::page(); |
|
| 73 | +} |
|
| 74 | 74 | } |
@@ -9,36 +9,36 @@ |
||
| 9 | 9 | |
| 10 | 10 | class Selector implements JsonSerializable |
| 11 | 11 | { |
| 12 | - /** |
|
| 12 | +/** |
|
| 13 | 13 | * @var array |
| 14 | 14 | */ |
| 15 | - private $aCall; |
|
| 15 | +private $aCall; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | +/** |
|
| 18 | 18 | * The constructor. |
| 19 | 19 | * |
| 20 | 20 | * @param string $sMode The selector mode: 'jq' or 'js' |
| 21 | 21 | * @param string $sPath The selector path |
| 22 | 22 | * @param mixed $xContext A context associated to the selector |
| 23 | 23 | */ |
| 24 | - public function __construct(string $sMode, string $sPath, $xContext = null) |
|
| 25 | - { |
|
| 26 | - $sName = trim($sPath) ?: 'this'; |
|
| 27 | - $this->aCall = ['_type' => 'select', '_name' => $sName, 'mode' => $sMode]; |
|
| 28 | - if($sName !== 'this' && $xContext !== null) |
|
| 29 | - { |
|
| 30 | - $this->aCall['context'] = is_a($xContext, JsonSerializable::class) ? |
|
| 31 | - $xContext->jsonSerialize() : $xContext; |
|
| 32 | - } |
|
| 33 | - } |
|
| 24 | +public function __construct(string $sMode, string $sPath, $xContext = null) |
|
| 25 | +{ |
|
| 26 | +$sName = trim($sPath) ?: 'this'; |
|
| 27 | +$this->aCall = ['_type' => 'select', '_name' => $sName, 'mode' => $sMode]; |
|
| 28 | +if($sName !== 'this' && $xContext !== null) |
|
| 29 | +{ |
|
| 30 | +$this->aCall['context'] = is_a($xContext, JsonSerializable::class) ? |
|
| 31 | + $xContext->jsonSerialize() : $xContext; |
|
| 32 | +} |
|
| 33 | +} |
|
| 34 | 34 | |
| 35 | - /** |
|
| 35 | +/** |
|
| 36 | 36 | * Convert this call to array, when converting the response into json. |
| 37 | 37 | * |
| 38 | 38 | * @return array |
| 39 | 39 | */ |
| 40 | - public function jsonSerialize(): array |
|
| 41 | - { |
|
| 42 | - return $this->aCall; |
|
| 43 | - } |
|
| 40 | +public function jsonSerialize(): array |
|
| 41 | +{ |
|
| 42 | +return $this->aCall; |
|
| 43 | +} |
|
| 44 | 44 | } |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | { |
| 26 | 26 | $sName = trim($sPath) ?: 'this'; |
| 27 | 27 | $this->aCall = ['_type' => 'select', '_name' => $sName, 'mode' => $sMode]; |
| 28 | - if($sName !== 'this' && $xContext !== null) |
|
| 28 | + if ($sName !== 'this' && $xContext !== null) |
|
| 29 | 29 | { |
| 30 | 30 | $this->aCall['context'] = is_a($xContext, JsonSerializable::class) ? |
| 31 | 31 | $xContext->jsonSerialize() : $xContext; |