/** * @param array|ArrayAccess $githubGist * @param array|ArrayAccess $githubComments * @return Gistlog */ public static function fromGitHub($githubGist, $githubComments = []) { $gistlog = new self(); $gistlog->id = $githubGist['id']; $gistlog->title = $githubGist['description']; $gistlog->content = array_values($githubGist['files'])[0]['content']; $gistlog->language = array_values($githubGist['files'])[0]['language']; $gistlog->author = $githubGist['owner']['login']; $gistlog->avatarUrl = $githubGist['owner']['avatar_url']; $gistlog->link = $githubGist['html_url']; $gistlog->public = $githubGist['public']; $gistlog->createdAt = Carbon::parse($githubGist['created_at']); $gistlog->updatedAt = Carbon::parse($githubGist['updated_at']); $gistlog->comments = collect($githubComments)->map(function ($comment) use($githubGist) { return Comment::fromGitHub($githubGist['id'], $comment); }); $gistlog->config = GistConfig::fromGitHub($githubGist); return $gistlog; }
/** @test */ public function it_returns_a_null_value_when_a_date_value_is_invalid() { $githubGist = $this->loadFixture('bb5ea4d44dbc5ccb77s7.json'); $config = GistConfig::fromGitHub($githubGist); $this->assertNull($config['published_on']); }