53 lines
1.4 KiB
PHP
53 lines
1.4 KiB
PHP
<?php
|
|
namespace PSC\Library\Calc\Option\Parser;
|
|
|
|
use PSC\Library\Calc\General\Parser\EdgeCollectionContainer;
|
|
use PSC\Library\Calc\Option\Type\Text as PSCText;
|
|
|
|
class Text extends Base
|
|
{
|
|
|
|
protected $element;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->element = new \PSC\Library\Calc\Option\Type\Text();
|
|
}
|
|
|
|
public function parseJSON(): PSCText
|
|
{
|
|
parent::parseJson();
|
|
|
|
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(): PSCText
|
|
{
|
|
parent::parseXML();
|
|
|
|
if($this->node->data) {
|
|
$this->element->setValue((string)$this->node->data);
|
|
}
|
|
|
|
if($this->element->getDefault() != null) {
|
|
$this->element->setValue($this->element->getDefault());
|
|
}
|
|
|
|
if($this->node->children()) {
|
|
$edgeCollectionContainerParser = new EdgeCollectionContainer();
|
|
$edgeCollectionContainerParser->fromXML($this->node);
|
|
$this->element->setEdgesCollectionContainer($edgeCollectionContainerParser->parseXML());
|
|
}
|
|
|
|
return $this->element;
|
|
}
|
|
|
|
}
|