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
|
|
|
|
2016-10-16 14:16:08 +00:00
|
|
|
use Vn\Lib\Type;
|
2016-10-17 12:36:52 +00:00
|
|
|
use Vn\Lib\Date;
|
|
|
|
use Vn\Lib\Time;
|
2016-08-26 12:43:45 +00:00
|
|
|
|
2018-05-23 10:14:20 +00:00
|
|
|
class Segment {
|
2016-08-26 12:43:45 +00:00
|
|
|
var $name;
|
|
|
|
var $values = [];
|
|
|
|
|
2018-05-23 10:14:20 +00:00
|
|
|
function getValue($key, $type = NULL) {
|
|
|
|
if ($key < 0 || $key >= count($this->values))
|
2016-08-26 12:43:45 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
$v = $this->values[$key];
|
|
|
|
|
2018-05-23 10:14:20 +00:00
|
|
|
switch ($type) {
|
2016-10-17 12:36:52 +00:00
|
|
|
case Type::DATE:
|
2018-05-23 10:14:20 +00:00
|
|
|
$tmp = new Date();
|
|
|
|
$tmp->setDate(substr($v, 0, 4), substr($v, 4, 2), substr($v, 6, 2));
|
2016-08-26 12:43:45 +00:00
|
|
|
return $tmp;
|
2016-10-17 12:36:52 +00:00
|
|
|
case Type::TIME:
|
2018-05-23 10:14:20 +00:00
|
|
|
$tmp = new Time();
|
|
|
|
$tmp->setTime(substr($v, 0, 2), substr($v, 2, 2));
|
2016-08-26 12:43:45 +00:00
|
|
|
return $tmp;
|
2016-10-17 12:36:52 +00:00
|
|
|
case Type::DOUBLE:
|
|
|
|
case Type::INTEGER:
|
2018-05-23 10:14:20 +00:00
|
|
|
Type::set($v, $type);
|
2016-08-26 12:43:45 +00:00
|
|
|
default:
|
|
|
|
return $v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|