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:
<?php
namespace Apptus\ESales\Connector\Report;
use Apptus\ESales\Connector\Time\IsoDateTime;
class Ad {
private $key;
private $attributeMap = array ();
public function __construct($key) {
$key = (string) $key;
if (strlen(trim($key)) === 0) {
throw new \InvalidArgumentException('Illegal value for argument key.');
}
$this->key = $key;
}
public function addAttribute($name, $value) {
if ($value === null) {
throw new \InvalidArgumentException('Attribute value can not be null.');
}
$this->attributeMap[$name] = new Attribute((string) $name, (string) $value);
}
public function key() {
return $this->key;
}
public function startTime() {
if (isset($this->attributeMap['start_time'])) {
return IsoDateTime::parse($this->attributeMap['start_time']->value());
}
return null;
}
public function endTime() {
if (isset($this->attributeMap['end_time'])) {
return IsoDateTime::parse($this->attributeMap['end_time']->value());
}
return null;
}
public function attributes() {
asort($this->attributeMap);
return array_values($this->attributeMap);
}
public function attribute($name) {
if (isset($this->attributeMap[$name])) {
return $this->attributeMap[$name];
}
return null;
}
public function __toString() {
$s = 'Ad{key=\'' . $this->key . '\', attributes=[';
$separator = '';
foreach ($this->attributes() as $entry) {
$s .= $separator . (string) $entry;
$separator = ', ';
}
$s .= ']}';
return $s;
}
}