Skip to content

Commit 11529c4

Browse files
committed
Make shouldCastAsDateTime private
1 parent 61272c3 commit 11529c4

File tree

2 files changed

+45
-22
lines changed

2 files changed

+45
-22
lines changed

src/GraphNode/GraphNode.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -275,28 +275,6 @@ public function isIso8601DateString($string)
275275
return preg_match($crazyInsaneRegexThatSomehowDetectsIso8601, $string) === 1;
276276
}
277277

278-
/**
279-
* Determines if a value from Graph should be cast to DateTime.
280-
*
281-
* @param string $key
282-
*
283-
* @return bool
284-
*/
285-
public function shouldCastAsDateTime($key)
286-
{
287-
return in_array($key, [
288-
'created_time',
289-
'updated_time',
290-
'start_time',
291-
'stop_time',
292-
'end_time',
293-
'backdated_time',
294-
'issued_at',
295-
'expires_at',
296-
'publish_time'
297-
], true);
298-
}
299-
300278
/**
301279
* Casts a date value from Graph to DateTime.
302280
*
@@ -337,4 +315,26 @@ public static function getNodeMap()
337315
{
338316
return static::$graphNodeMap;
339317
}
318+
319+
/**
320+
* Determines if a value from Graph should be cast to DateTime.
321+
*
322+
* @param string $key
323+
*
324+
* @return bool
325+
*/
326+
private function shouldCastAsDateTime($key)
327+
{
328+
return in_array($key, [
329+
'created_time',
330+
'updated_time',
331+
'start_time',
332+
'stop_time',
333+
'end_time',
334+
'backdated_time',
335+
'issued_at',
336+
'expires_at',
337+
'publish_time'
338+
], true);
339+
}
340340
}

tests/GraphNode/GraphNodeTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,29 @@ public function testAGraphNodeCanInstantiateWithData()
4343
$this->assertEquals(['foo' => 'bar'], $backingData);
4444
}
4545

46+
/**
47+
* @dataProvider provideDateTimeFieldNames
48+
*/
49+
public function testIsCastDateTimeFieldsToDateTime($fieldName)
50+
{
51+
$graphNode = new GraphNode([$fieldName => '1989-11-02']);
52+
53+
$this->assertInstanceOf(\DateTime::class, $graphNode->getField($fieldName));
54+
}
55+
56+
public static function provideDateTimeFieldNames()
57+
{
58+
yield ['created_time'];
59+
yield ['updated_time'];
60+
yield ['start_time'];
61+
yield ['stop_time'];
62+
yield ['end_time'];
63+
yield ['backdated_time'];
64+
yield ['issued_at'];
65+
yield ['expires_at'];
66+
yield ['publish_time'];
67+
}
68+
4669
public function testDatesThatShouldBeCastAsDateTimeObjectsAreDetected()
4770
{
4871
$graphNode = new GraphNode();

0 commit comments

Comments
 (0)