83 lines
2.6 KiB
PHP
83 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace PSC\Library\Calc\Option\Parser;
|
|
|
|
use PSC\Library\Calc\General\Parser\EdgeCollectionContainer;
|
|
use PSC\Library\Calc\Option\Type\Input as PSCInput;
|
|
|
|
class Input extends Base
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->element = new \PSC\Library\Calc\Option\Type\Input();
|
|
}
|
|
|
|
public function parseJson(): PSCInput
|
|
{
|
|
parent::parseJson();
|
|
|
|
if (isset($this->json['placeHolder'])) {
|
|
$this->element->setPlaceHolder((string) $this->json['placeHolder']);
|
|
}
|
|
if (isset($this->json['minValue'])) {
|
|
$this->element->setMinValue((int) $this->json['minValue']);
|
|
}
|
|
|
|
if (isset($this->json['minCalc'])) {
|
|
$this->element->setMinCalc((string) $this->json['minCalc']);
|
|
}
|
|
|
|
if (isset($this->json['maxValue'])) {
|
|
$this->element->setMaxValue((int) $this->json['maxValue']);
|
|
}
|
|
|
|
if (isset($this->json['maxCalc'])) {
|
|
$this->element->setMaxCalc((string) $this->json['maxCalc']);
|
|
}
|
|
|
|
if (isset($this->json['dependencys']) && count($this->json['dependencys']) > 0) {
|
|
$edgeCollectionContainerParser = new EdgeCollectionContainer();
|
|
$edgeCollectionContainerParser->fromJson($this->json['dependencys']);
|
|
$this->element->setEdgesCollectionContainer($edgeCollectionContainerParser->parseJson());
|
|
}
|
|
|
|
return $this->element;
|
|
}
|
|
|
|
public function parseXML(): PSCInput
|
|
{
|
|
parent::parseXML();
|
|
|
|
if (isset($this->node['min'])) {
|
|
$this->element->setMinValue((int) $this->node['min']);
|
|
}
|
|
|
|
if (isset($this->node['min_calc'])) {
|
|
$this->element->setMinCalc((string) $this->node['min_calc']);
|
|
}
|
|
|
|
if (isset($this->node['max'])) {
|
|
$this->element->setMaxValue((int) $this->node['max']);
|
|
}
|
|
|
|
if (isset($this->node['max_calc'])) {
|
|
$this->element->setMaxCalc((string) $this->node['max_calc']);
|
|
}
|
|
|
|
if (isset($this->node['pattern'])) {
|
|
$this->element->setPattern((string) $this->node['pattern']);
|
|
}
|
|
if (isset($this->node['placeholder'])) {
|
|
$this->element->setPlaceHolder((string) $this->node['placeholder']);
|
|
}
|
|
|
|
if ($this->node->children()) {
|
|
$edgeCollectionContainerParser = new EdgeCollectionContainer();
|
|
$edgeCollectionContainerParser->fromXML($this->node);
|
|
$this->element->setEdgesCollectionContainer($edgeCollectionContainerParser->parseXML());
|
|
}
|
|
|
|
return $this->element;
|
|
}
|
|
}
|