Frame.php 789 Bytes
Newer Older
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
<?php

	/**
	* @package Net_EPP
	*/
	abstract class Net_EPP_Frame extends DomDocument {

		const EPP_URN		= 'urn:ietf:params:xml:ns:epp-1.0';
		const SCHEMA_URI	= 'http://www.w3.org/2001/XMLSchema-instance';
		const TEMPLATE		= '<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"></epp>';

		function __construct($type) {
			parent::__construct('1.0', 'UTF-8');

			$this->loadXML(self::TEMPLATE);

			$type = strtolower($type);
			if (!in_array($type, array('hello', 'greeting', 'command', 'response'))) trigger_error("Invalid argument value '$type' for \$type", E_USER_ERROR);

			$this->epp = $this->firstChild;
			$this->body = $this->createElement($type);
			$this->epp->appendChild($this->body);
		}

		function friendly() {
			return str_replace('><', ">\n<", $this->saveXML());
		}
	}
?>