Skip to content

Commit 0673ccd

Browse files
committed
Remove asJson from GraphNode
1 parent 21e76be commit 0673ccd

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

src/GraphNode/GraphNode.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,6 @@ public function asArray()
102102
}, $this->fields);
103103
}
104104

105-
/**
106-
* Get all fields as JSON.
107-
*
108-
* @param int $options
109-
*
110-
* @return string
111-
*/
112-
public function asJson($options = 0)
113-
{
114-
return json_encode($this->uncastFields(), $options);
115-
}
116-
117105
/**
118106
* Get an iterator for the fields.
119107
*
@@ -184,7 +172,7 @@ public function offsetUnset($key)
184172
*/
185173
public function __toString()
186174
{
187-
return $this->asJson();
175+
return json_encode($this->uncastFields());
188176
}
189177

190178
/**

tests/GraphNode/GraphNodeTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ public function testGettingGraphNodeAsAnArrayWillNotUncastTheDateTimeObject()
118118
$this->assertInstanceOf(\DateTime::class, $graphNodeAsArray['created_time']);
119119
}
120120

121-
public function testGettingAGraphNodeAsJSONWillSafelyRepresentDateTimes()
121+
public function testGettingAGraphNodeAsAStringWillSafelyRepresentDateTimes()
122122
{
123123
$graphNode = new GraphNode([
124124
'id' => '123',
125125
'created_time' => '2014-07-15T03:44:53+0000',
126126
]);
127127

128-
$graphNodeAsString = $graphNode->asJson();
128+
$graphNodeAsString = (string) $graphNode;
129129

130130
$this->assertEquals('{"id":"123","created_time":"2014-07-15T03:44:53+0000"}', $graphNodeAsString);
131131
}
@@ -186,11 +186,11 @@ public function testAnArrayCanBeInjectedViaTheConstructor()
186186
$this->assertEquals(['foo', 'bar'], $graphNode->asArray());
187187
}
188188

189-
public function testACollectionCanBeConvertedToProperJson()
189+
public function testAGraphNodeCanBeConvertedToAString()
190190
{
191191
$graphNode = new GraphNode(['foo', 'bar', 123]);
192192

193-
$graphNodeAsString = $graphNode->asJson();
193+
$graphNodeAsString = (string) $graphNode;
194194

195195
$this->assertEquals('["foo","bar",123]', $graphNodeAsString);
196196
}

0 commit comments

Comments
 (0)