コード例 #1
0
ファイル: Comment.php プロジェクト: fgrosse/gitlab-api
 public static function fromArray(array $data)
 {
     $comment = new self();
     $comment->note = $data['note'];
     $comment->author = User::fromArray($data['author']);
     return $comment;
 }
コード例 #2
0
ファイル: UserTest.php プロジェクト: fgrosse/gitlab-api
 public function testFromArray()
 {
     $actual = User::fromArray(['id' => 1, 'username' => 'john_smith', 'name' => 'John Smith', 'state' => 'active', 'avatar_url' => 'http=>//localhost=>3000/uploads/user/avatar/1/cd8.jpeg']);
     $this->assertEquals(1, $actual->id);
     $this->assertEquals('john_smith', $actual->username);
     $this->assertEquals('John Smith', $actual->name);
     $this->assertEquals('active', $actual->state);
     $this->assertEquals('http=>//localhost=>3000/uploads/user/avatar/1/cd8.jpeg', $actual->avatarUrl);
 }
コード例 #3
0
ファイル: MergeRequest.php プロジェクト: fgrosse/gitlab-api
 /**
  * Parse a MergeRequest from an array using the format that is returned by gitlab.
  * @param array $data
  * @return MergeRequest
  */
 public static function fromArray(array $data)
 {
     $mergeRequest = new self();
     $mergeRequest->id = $data['id'];
     $mergeRequest->iid = $data['iid'];
     $mergeRequest->targetBranch = $data['target_branch'];
     $mergeRequest->sourceBranch = $data['source_branch'];
     $mergeRequest->projectId = $data['project_id'];
     $mergeRequest->title = $data['title'];
     $mergeRequest->description = $data['description'];
     $mergeRequest->state = $data['state'];
     $mergeRequest->upVotes = $data['upvotes'];
     $mergeRequest->downVotes = $data['downvotes'];
     $mergeRequest->author = User::fromArray($data['author']);
     if (isset($data['assignee'])) {
         $mergeRequest->assignee = User::fromArray($data['assignee']);
     }
     return $mergeRequest;
 }