| 1 | <?php |
||
| 9 | class Counter implements CounterInterface |
||
| 10 | { |
||
| 11 | const TYPE_LIVE_INTERNET = 'LiveInternet'; |
||
| 12 | const TYPE_GOOGLE_ANALYTICS = 'Google'; |
||
| 13 | const TYPE_MEDIASCOPE = 'Mediascope'; |
||
| 14 | const TYPE_MAIL_RU = 'MailRu'; |
||
| 15 | const TYPE_RAMBLER = 'Rambler'; |
||
| 16 | const TYPE_YANDEX = 'Yandex'; |
||
| 17 | const TYPE_CUSTOM = 'custom'; |
||
| 18 | |||
| 19 | private $type; |
||
| 20 | private $id; |
||
| 21 | private $url; |
||
| 22 | |||
| 23 | 54 | public function __construct($type, $id = null, $url = null) |
|
| 24 | { |
||
| 25 | 54 | $this->type = $type; |
|
| 26 | 54 | $this->id = $id; |
|
| 27 | 54 | $this->url = $url; |
|
| 28 | |||
| 29 | 54 | if ($type == self::TYPE_CUSTOM && $url === null) { |
|
| 30 | 6 | throw new \UnexpectedValueException('Please set url for custom counter'); |
|
| 31 | } |
||
| 32 | |||
| 33 | 48 | if ($type != self::TYPE_CUSTOM && $id === null) { |
|
| 34 | 6 | throw new \UnexpectedValueException('Please set id for non custom counter'); |
|
| 35 | } |
||
| 36 | 42 | } |
|
| 37 | |||
| 38 | 12 | public function appendTo(ChannelInterface $channel) |
|
| 43 | |||
| 44 | 18 | public function asXML() |
|
| 55 | } |