XRL  latest
Simple XML-RPC Library (both client and server)
Base64.php
1 <?php
2 /*
3  * This file is part of XRL, a simple XML-RPC Library for PHP.
4  *
5  * Copyright (c) 2012, XRL Team. All rights reserved.
6  * XRL is licensed under the 3-clause BSD License.
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
12 namespace fpoirotte\XRL\Types;
13 
21 {
23  public function write(\XMLWriter $writer, \DateTimeZone $timezone, $stringTag)
24  {
25  $writer->writeElement('base64', base64_encode($this->value));
26  }
27 
29  protected static function parse($value, \DateTimeZone $timezone = null)
30  {
31  $res = base64_decode($value, true);
32  if ($res === false) {
33  throw new \InvalidArgumentException('Expected base64-encoded input');
34  }
35  return $res;
36  }
37 }
The XML-RPC "base64" type.
Definition: Base64.php:20
The XML-RPC "string" type.
Definition: StringType.php:20
$value
Current value associated with this object.
write(\XMLWriter $writer,\DateTimeZone $timezone, $stringTag)
Definition: Base64.php:23
static parse($value,\DateTimeZone $timezone=null)
Definition: Base64.php:29