Пример #1
0
 /**
  * @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);
     });
     return $gistlog;
 }
Пример #2
0
 /** @test */
 public function can_get_absolute_url_to_gist_comment_on_github()
 {
     $githubComment = $this->loadFixture('002ed429c7c21ab89300/comments.json')[0];
     $comment = Comment::fromGitHub('002ed429c7c21ab89300', $githubComment);
     $this->assertEquals('https://gist.github.com/002ed429c7c21ab89300#comment-' . $comment->id, $comment->link());
 }