Overview

Namespaces

  • Apptus
    • ESales
      • Connector
        • Report
        • Time
    • Util
      • Cache
  • PHP
  • Overview
  • Namespace
  • Class
  • Tree
  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 super class for the different reports.
 */
abstract class Report {
    /**
     * @internal
     */
    public static function checkElem(\SimpleXMLElement $tree, $child) {
        if (!isset($tree->$child)) {
            throw new FormatException('Missing element in XML: ' . $child . '. Expected in ' . $tree->getName() . '.');
        }
    }

    /**
     * @internal
     */
    public static function checkAttr(\SimpleXMLElement $tree, $attr) {
        if (!isset($tree->attributes()->$attr)) {
            throw new FormatException('Missing attribute in XML: ' . $attr . '. Expected in ' . $tree->getName() . '.');
        }
    }

    /**
     * @internal
     * @param mixed
     * @return number
     */
    public static function parseLong($x) {
        $xint = (int) $x;
        if ($xint === 2147483647 && $x !== '2147483647') {
            return (float) $x;
        }
        return $xint;
    }

    /**
     * @internal
     * @param mixed
     * @return float
     */
    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;
    /** @internal */
    protected $tz;

    /**
     * @internal
     */
    public function __construct(TimeInterval $interval, \SimpleXMLElement $asXml, \DateTimeZone $tz) {
        $this->interval = $interval;
        $this->asXml = $asXml;
        $this->tz = $tz;
    }

    /**
     * @return TimeInterval
     *            The time range used to generate this report.
     */
    public function timeInterval() {
        return $this->interval;
    }

    /**
     * Writes the report to a file. The report is written in plain text and ';' is used as separator.
     *
     * @param string
     *            The file to write the report to.
     */
    public abstract function exportToExcel($file);

    /**
     * Writes the XML representation for this report to a file.
     *
     * @param string
     *            The file to write the XML document to.
     * @return mixed If the <i>file</i> isn't specified, this function
     * returns a string on success and false on error. If the
     * parameter is specified, it returns true if the file was written
     * successfully and false otherwise.
     */
    public function exportToXml($file = null) {
        if ($file == null) {
            return $this->asXml->asXML();
        }
        return $this->asXml->asXML($file);
    }

    /**
     * @internal
     */
    protected function isoDateTimeFormat(\DateTime $dt) {
        return $dt->format('Y-m-d H:i:s');
    }
}
Apptus ESales Connector PHP API documentation generated by ApiGen