Example #1
0
 public static function castFrom(Model\User $user)
 {
     $cast = new static($user->id, $user->getClient());
     foreach (static::$properties as $property) {
         $cast->{$property} = $user->{$property};
     }
     return $cast;
 }
Example #2
0
 /**
  * @param Client $client
  * @param Noteable $type
  * @param array $data
  * @return mixed
  */
 public static function fromArray(Client $client, Noteable $type, array $data)
 {
     $comment = new static($type, $client);
     if (isset($data['author'])) {
         $data['author'] = User::fromArray($client, $data['author']);
     }
     return $comment->hydrate($data);
 }
Example #3
0
 /**
  * @param Client  $client
  * @param Project $project
  * @param array   $data
  * @return Snippet
  */
 public static function fromArray(Client $client, Project $project, array $data)
 {
     $snippet = new static($project, $data['id'], $client);
     if (isset($data['author'])) {
         $data['author'] = User::fromArray($client, $data['author']);
     }
     return $snippet->hydrate($data);
 }
Example #4
0
 /**
  * @param Client  $client
  * @param Project $project
  * @param array   $data
  * @return Commit
  */
 public static function fromArray(Client $client, Project $project, array $data)
 {
     $commit = new static($project, $data['id'], $client);
     if (isset($data['parents'])) {
         $parents = array();
         foreach ($data['parents'] as $parent) {
             $parents[] = static::fromArray($client, $project, $parent);
         }
         $data['parents'] = $parents;
     }
     if (isset($data['author'])) {
         $data['author'] = User::fromArray($client, $data['author']);
     }
     if (isset($data['committer'])) {
         $data['committer'] = User::fromArray($client, $data['committer']);
     }
     return $commit->hydrate($data);
 }
Example #5
0
 /**
  * @param Client  $client
  * @param Project $project
  * @param array   $data
  * @return MergeRequest
  */
 public static function fromArray(Client $client, Project $project, array $data)
 {
     $mr = new static($project, $data['id'], $client);
     if (isset($data['author'])) {
         $data['author'] = User::fromArray($client, $data['author']);
     }
     if (isset($data['assignee'])) {
         $data['assignee'] = User::fromArray($client, $data['assignee']);
     }
     if (isset($data['milestone'])) {
         $data['milestone'] = Milestone::fromArray($client, $project, $data['milestone']);
     }
     if (isset($data['files'])) {
         $files = array();
         foreach ($data['files'] as $file) {
             $files[] = File::fromArray($client, $project, $file);
         }
         $data['files'] = $files;
     }
     return $mr->hydrate($data);
 }
Example #6
0
 /**
  * @param int $user_id
  * @param int $access_level
  * @return User
  */
 public function addMember($user_id, $access_level)
 {
     $data = $this->api('groups')->addMember($this->id, $user_id, $access_level);
     return User::fromArray($this->getClient(), $data);
 }
Example #7
0
 /**
  * @param int $user_id
  * @param int $access_level
  * @return User
  */
 public function saveMember($user_id, $access_level)
 {
     $data = $this->api('projects')->saveMember($this->id, $user_id, $access_level);
     return User::fromArray($this->getClient(), $data);
 }
Example #8
0
 /**
  * @return User
  */
 public function me()
 {
     $data = $this->api('users')->show();
     return User::fromArray($this->getClient(), $data);
 }