Beispiel #1
0
 public function testMaybeDecode()
 {
     $data = ['a' => 'A', 'true' => true];
     $validJson = json_encode($data);
     $actual = Helpers::maybeDecode($validJson);
     $this->assertEquals(json_decode($validJson, false), $actual, 'failed to decode a valid json string');
     $invalidJson = '{a: }';
     $actual = Helpers::maybeDecode($invalidJson);
     $this->assertEquals('{a: }', $actual, 'failed to return invalid json');
     $almostJson = '01.01.1970';
     $actual = Helpers::maybeDecode($almostJson);
     $this->assertEquals('01.01.1970', $actual, 'failed to return almost json');
 }
Beispiel #2
0
 /**
  * Maybe decode a meta value
  *
  * @param $value
  * @return mixed
  */
 public function getValueAttribute($value)
 {
     return Helpers::maybeDecode($value);
 }