0
1
Fork 0
hedera-web-mindshore/rest/edi/lib/segment.php

37 lines
634 B
PHP

<?php
namespace Edi;
use Vn\Lib\Type;
use Vn\Lib\Date;
use Vn\Lib\Time;
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:
Type::set($v, $type);
default:
return $v;
}
}
}