forked from eschnou/php-atom-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AtomPersonConstructAdapter.php
68 lines (56 loc) · 1.83 KB
/
AtomPersonConstructAdapter.php
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
<?php
require_once 'ExtensibleAtomAdapter.php';
require_once 'SimpleAtomAdapter.php';
class AtomPersonConstructAdapter extends ExtensibleAtomAdapter {
protected $_name;
protected $_uri;
protected $_email;
public function getEmail() {
return $this->_email->value;
}
public function getName() {
return $this->_name->value;
}
public function getUri() {
return $this->_uri->value;
}
public function setEmail($value) {
if (!isset($this->_email)) {
$email = $this->_addElement(AtomNS::NS, AtomNS::EMAIL_ELEMENT, $value);
$this->_email = new SimpleAtomAdapter(AtomNS::EMAIL_ELEMENT, $email);
return;
}
$this->_email->value = $value;
}
public function setName($value) {
if (!isset($this->_name)) {
$name = $this->_addElement(AtomNS::NS, AtomNS::NAME_ELEMENT, $value);
$this->_name = new SimpleAtomAdapter(AtomNS::NAME_ELEMENT, $name);
return;
}
$this->_name->value = $value;
}
public function setUri($value) {
if (!isset($this->_uri)) {
$uri = $this->_addElement(AtomNS::NS, AtomNS::URI_ELEMENT, $value);
$this->_uri = new SimpleAtomAdapter(AtomNS::URI_ELEMENT, $uri);
return;
}
$this->_uri->value = $value;
}
public function __construct($adapterType, $data, $data_is_url=false) {
parent::__construct($adapterType, $data, $data_is_url);
$this->_init();
}
protected function _init() {
if (isset($this->_element[AtomNS::NAME_ELEMENT][0])) {
$this->_name = new SimpleAtomAdapter(AtomNS::NAME_ELEMENT, $this->_element[AtomNS::NAME_ELEMENT][0]);
}
if (isset($this->_element[AtomNS::URI_ELEMENT][0])) {
$this->_uri = new SimpleAtomAdapter(AtomNS::URI_ELEMENT, $this->_element[AtomNS::URI_ELEMENT][0]);
}
if (isset($this->_element[AtomNS::EMAIL_ELEMENT][0])) {
$this->_email = new SimpleAtomAdapter(AtomNS::EMAIL_ELEMENT, $this->_element[AtomNS::EMAIL_ELEMENT][0]);
}
}
}