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 ('vn/lib/type.php');
|
|
|
|
|
|
|
|
class Segment
|
|
|
|
{
|
|
|
|
var $name;
|
|
|
|
var $values = [];
|
|
|
|
|
|
|
|
function getValue ($key, $type = NULL)
|
|
|
|
{
|
|
|
|
if ($key < 0 || $key >= count ($this->values))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
$v = $this->values[$key];
|
|
|
|
|
|
|
|
switch ($type)
|
|
|
|
{
|
|
|
|
case TYPE_DATE:
|
|
|
|
$tmp = new \Date ();
|
|
|
|
$tmp->setDate (substr ($v, 0, 4), substr ($v, 4, 2), substr ($v, 6, 2));
|
|
|
|
return $tmp;
|
|
|
|
case TYPE_TIME:
|
|
|
|
$tmp = new \Time ();
|
|
|
|
$tmp->setTime (substr ($v, 0, 2), substr ($v, 2, 2));
|
|
|
|
return $tmp;
|
|
|
|
case TYPE_DOUBLE:
|
|
|
|
case TYPE_INTEGER:
|
|
|
|
set_type ($v, $type);
|
|
|
|
default:
|
|
|
|
return $v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|