2016-08-26 12:43:45 +00:00
|
|
|
<?php
|
|
|
|
|
2016-08-31 11:53:46 +00:00
|
|
|
namespace Edi;
|
2016-08-26 12:43:45 +00:00
|
|
|
|
|
|
|
require_once (__DIR__.'/segment.php');
|
|
|
|
|
|
|
|
class Section
|
|
|
|
{
|
|
|
|
var $name;
|
|
|
|
var $parent = NULL;
|
|
|
|
var $segments = [];
|
|
|
|
var $childs = [];
|
|
|
|
|
|
|
|
function getValue ($name, $key, $type = NULL, $subname = NULL)
|
|
|
|
{
|
|
|
|
foreach ($this->segments as $segment)
|
|
|
|
if ($segment->name == $name
|
|
|
|
&& (!$subname || $segment->values[1] == $subname))
|
|
|
|
return $segment->getValue ($key, $type);
|
|
|
|
|
|
|
|
if ($this->parent)
|
|
|
|
return $this->parent->getValue ($name, $key, $type, $subname);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|