protected function doReadJsonContentsFromFileBy($languageCode, $cacheKey) { $contents = json_decode(file_get_contents($this->getFileForLanguageCode($languageCode)), true); if ($contents !== null && json_last_error() === JSON_ERROR_NONE) { $this->cache->save($cacheKey, $contents, $this->ttl); return $contents; } throw new RuntimeException(ErrorCode::getMessageFromJsonErrorCode(json_last_error())); }
public function testGetMessageFromJsonErrorCode() { $this->assertInternalType('string', ErrorCode::getMessageFromJsonErrorCode('Foo')); $contents = json_decode('{ Foo: Bar }'); $this->assertInternalType('string', ErrorCode::getMessageFromJsonErrorCode(json_last_error())); }