1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112:
<?php
namespace Apptus\ESales\Connector\Report;
use Apptus\ESales\Connector\Time\TimeInterval;
abstract class Report {
public static function checkElem(\SimpleXMLElement $tree, $child) {
if (!isset($tree->$child)) {
throw new FormatException('Missing element in XML: ' . $child . '. Expected in ' . $tree->getName() . '.');
}
}
public static function checkAttr(\SimpleXMLElement $tree, $attr) {
if (!isset($tree->attributes()->$attr)) {
throw new FormatException('Missing attribute in XML: ' . $attr . '. Expected in ' . $tree->getName() . '.');
}
}
public static function parseLong($x) {
$xint = (int) $x;
if ($xint === 2147483647 && $x !== '2147483647') {
return (float) $x;
}
return $xint;
}
public static function parseDouble($x) {
switch (strtolower((string) $x)) {
case 'nan':
return NAN;
case 'inf':
return INF;
case '-inf':
return -INF;
}
return (double) $x;
}
private $interval;
private $asXml;
protected $tz;
public function __construct(TimeInterval $interval, \SimpleXMLElement $asXml, \DateTimeZone $tz) {
$this->interval = $interval;
$this->asXml = $asXml;
$this->tz = $tz;
}
public function timeInterval() {
return $this->interval;
}
public abstract function exportToExcel($file);
public function exportToXml($file = null) {
if ($file == null) {
return $this->asXml->asXML();
}
return $this->asXml->asXML($file);
}
protected function isoDateTimeFormat(\DateTime $dt) {
return $dt->format('Y-m-d H:i:s');
}
}