|
13 | 13 | use DOMElement; |
14 | 14 | use SAML2\Constants; |
15 | 15 | use SAML2\DOMDocumentFactory; |
| 16 | +use Serializable; |
16 | 17 |
|
17 | | -abstract class NameIDType |
| 18 | +abstract class NameIDType implements Serializable |
18 | 19 | { |
19 | 20 | use IDNameQualifiersTrait; |
20 | 21 |
|
@@ -197,6 +198,62 @@ public function toXML(DOMElement $parent = null) : DOMElement |
197 | 198 | } |
198 | 199 |
|
199 | 200 |
|
| 201 | + /** |
| 202 | + * Serialize this NameID. |
| 203 | + * |
| 204 | + * @return string The NameID serialized. |
| 205 | + */ |
| 206 | + public function serialize() : string |
| 207 | + { |
| 208 | + return serialize([ |
| 209 | + 'NameQualifier' => $this->NameQualifier, |
| 210 | + 'SPNameQualifier' => $this->SPNameQualifier, |
| 211 | + 'nodeName' => $this->nodeName, |
| 212 | + 'Format' => $this->Format, |
| 213 | + 'SPProvidedID' => $this->SPProvidedID, |
| 214 | + 'value' => $this->value |
| 215 | + ]); |
| 216 | + } |
| 217 | + |
| 218 | + |
| 219 | + /** |
| 220 | + * Un-serialize this NameID. |
| 221 | + * |
| 222 | + * @param string $serialized The serialized NameID. |
| 223 | + * @return void |
| 224 | + * |
| 225 | + * Type hint not possible due to upstream method signature |
| 226 | + */ |
| 227 | + public function unserialize($serialized) : void |
| 228 | + { |
| 229 | + $unserialized = unserialize($serialized); |
| 230 | + foreach ($unserialized as $k => $v) { |
| 231 | + $this->$k = $v; |
| 232 | + } |
| 233 | + } |
| 234 | + |
| 235 | + |
| 236 | + public function __serialize(): array |
| 237 | + { |
| 238 | + return [ |
| 239 | + 'NameQualifier' => $this->getNameQualifier(), |
| 240 | + 'SPNameQualifier' => $this->getSPNameQualifier(), |
| 241 | + 'nodeName' => $this->nodeName, |
| 242 | + 'Format' => $this->Format, |
| 243 | + 'SPProvidedID' => $this->SPProvidedID, |
| 244 | + 'value' => $this->value |
| 245 | + ]; |
| 246 | + } |
| 247 | + |
| 248 | + |
| 249 | + public function __unserialize($serialized): void |
| 250 | + { |
| 251 | + foreach ($serialized as $k => $v) { |
| 252 | + $this->$k = $v; |
| 253 | + } |
| 254 | + } |
| 255 | + |
| 256 | + |
200 | 257 | /** |
201 | 258 | * Get a string representation of this BaseIDType object. |
202 | 259 | * |
|
0 commit comments