blob: 23c03ed1c4915ed0c0bcd925e21961b76a460e99 (
plain)
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
69
|
<?php
namespace Pheanstalk\Response;
use Pheanstalk\Response;
/**
* A response with an ArrayObject interface to key=>value data
*
* @author Paul Annesley
* @package Pheanstalk
* @license http://www.opensource.org/licenses/mit-license.php
*/
class ArrayResponse
extends \ArrayObject
implements Response
{
private $_name;
/**
* @param string $name
* @param array $data
*/
public function __construct($name, $data)
{
$this->_name = $name;
parent::__construct($data);
}
/* (non-phpdoc)
* @see Response::getResponseName()
*/
public function getResponseName()
{
return $this->_name;
}
/**
* Object property access to ArrayObject data.
*/
public function __get($property)
{
$key = $this->_transformPropertyName($property);
return isset($this[$key]) ? $this[$key] : null;
}
/**
* Object property access to ArrayObject data.
*/
public function __isset($property)
{
$key = $this->_transformPropertyName($property);
return isset($this[$key]);
}
// ----------------------------------------
/**
* Tranform underscored property name to hyphenated array key.
* @param string
* @return string
*/
private function _transformPropertyName($propertyName)
{
return str_replace('_', '-', $propertyName);
}
}
|