Skip to content

Commit bc70fee

Browse files
committed
No longer mucking with base64_encode and decode.
1 parent 481eb99 commit bc70fee

File tree

4 files changed

+16
-40
lines changed

4 files changed

+16
-40
lines changed

src/Event/EventClient.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ public function fire(UserEvent $event, WriteOptions $writeOptions = null)
5050
if ('' !== ($payload = $event->getPayload()))
5151
$r->setBody($payload);
5252

53-
var_dump($payload);exit;
54-
5553
list($duration, $response, $err) = $this->requireOK($this->doRequest($r));
5654
$wm = $this->buildWriteMeta($duration);
5755

@@ -62,6 +60,9 @@ public function fire(UserEvent $event, WriteOptions $writeOptions = null)
6260
if ($err !== null)
6361
return [null, $wm, $err];
6462

63+
if (isset($data['Payload']))
64+
$data['Payload'] = base64_decode($data['Payload']);
65+
6566
return [new UserEvent($data), $wm, null];
6667
}
6768

@@ -95,6 +96,9 @@ public function eventList($name = '', QueryOptions $queryOptions = null)
9596
$events = array();
9697
foreach($data as $event)
9798
{
99+
if (isset($event['Payload']))
100+
$event['Payload'] = base64_decode($event['Payload']);
101+
98102
$events[] = new UserEvent($event);
99103
}
100104

src/Event/UserEvent.php

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,6 @@
2525
*/
2626
class UserEvent extends AbstractDefinedCollection
2727
{
28-
/**
29-
* UserEvent constructor.
30-
* @param array $data
31-
*/
32-
public function __construct(array $data = array())
33-
{
34-
parent::__construct();
35-
foreach($data as $k=>$v)
36-
{
37-
switch($k)
38-
{
39-
case 'Payload':
40-
$this->setPayload($v);
41-
break;
42-
default:
43-
$this[$k] = $v;
44-
}
45-
}
46-
}
47-
4828
/**
4929
* @return array
5030
*/
@@ -105,7 +85,7 @@ public function setName($name)
10585
*/
10686
public function getPayload()
10787
{
108-
return $this->_storage['Payload'];
88+
return (string)$this->_storage['Payload'];
10989
}
11090

11191
/**
@@ -119,14 +99,6 @@ public function setPayload($payload)
11999
return $this;
120100
}
121101

122-
/**
123-
* @return string
124-
*/
125-
public function getDecodedPayload()
126-
{
127-
return base64_decode((string)$this->_storage['Payload']);
128-
}
129-
130102
/**
131103
* @return string
132104
*/

src/KV/KVClient.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@ public function get($key, QueryOptions $queryOptions = null)
6464
if (null !== $err)
6565
return [null, $qm, $err];
6666

67-
return [new KVPair(reset($data)), $qm, null];
67+
$data = $data[0];
68+
69+
if (isset($data['Value']))
70+
$data['Value'] = base64_decode($data['Value']);
71+
72+
return [new KVPair($data), $qm, null];
6873
}
6974

7075
/**
@@ -105,6 +110,9 @@ public function valueList($prefix, QueryOptions $queryOptions = null)
105110
$kvPairs = array();
106111
foreach($data as $v)
107112
{
113+
if (isset($v['Value']))
114+
$v['Value'] = base64_decode($v['Value']);
115+
108116
$kvp = new KVPair($v);
109117
$kvPairs[$kvp->getKey()] = $kvp;
110118
}

src/KV/KVPair.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,6 @@ public function setValue($value)
9191
return $this;
9292
}
9393

94-
/**
95-
* @return string
96-
*/
97-
public function getDecodedValue()
98-
{
99-
return base64_decode((string)$this['Value']);
100-
}
101-
10294
/**
10395
* @return int
10496
*/

0 commit comments

Comments
 (0)