|  | @@ -184,29 +184,39 @@ namespace Gogs\API\Request {
 | 
	
		
			
				|  |  |           * 
 | 
	
		
			
				|  |  |           * @param int $flag Defines sorting algorithm to use
 | 
	
		
			
				|  |  |           * @param bool $asc Ascending order
 | 
	
		
			
				|  |  | -         * @return \Gogs\Lib\Collection
 | 
	
		
			
				|  |  | +         * @return Repos
 | 
	
		
			
				|  |  |           */
 | 
	
		
			
				|  |  |          public function sort_by(int $flag = Collection::SORT_INDEX, bool $asc = false) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            $repos = new Repos($this->url, $this->token, $this->owner);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              switch ($flag) {
 | 
	
		
			
				|  |  |              case self::SORT_CREATED:
 | 
	
		
			
				|  |  | -                return ($sort = $this->sort(function(Repo $a, Repo $b) {
 | 
	
		
			
				|  |  | +                $sort = $this->sort(function(Repo $a, Repo $b) {
 | 
	
		
			
				|  |  |                      $adate = new \DateTime($a->created_at);
 | 
	
		
			
				|  |  |                      $bdate = new \DateTime($b->created_at);
 | 
	
		
			
				|  |  |                      return ($adate == $bdate ? 0 : ($adate > $bdate ? 1 : -1));
 | 
	
		
			
				|  |  | -                })) ? ($asc ? $sort->reverse() : $sort) : false;
 | 
	
		
			
				|  |  | +                });
 | 
	
		
			
				|  |  |              case self::SORT_UPDATED:
 | 
	
		
			
				|  |  | -                return ($sort = $this->sort(function(Repo $a, Repo $b) {
 | 
	
		
			
				|  |  | +                $sort = $this->sort(function(Repo $a, Repo $b) {
 | 
	
		
			
				|  |  |                      $adate = new \DateTime($a->updated_at);
 | 
	
		
			
				|  |  |                      $bdate = new \DateTime($b->updated_at);
 | 
	
		
			
				|  |  |                      return ($adate == $bdate ? 0 : ($adate > $bdate ? 1 : -1));
 | 
	
		
			
				|  |  | -                })) ? ($asc ? $sort->reverse() : $sort) : false;
 | 
	
		
			
				|  |  | +                });
 | 
	
		
			
				|  |  |              case self::SORT_OWNER:
 | 
	
		
			
				|  |  | -                return ($sort = $this->sort(function(Repo $a, Repo $b) {
 | 
	
		
			
				|  |  | +                $sort = $this->sort(function(Repo $a, Repo $b) {
 | 
	
		
			
				|  |  |                      return strcmp($a->owner->username, $b->owner->username);
 | 
	
		
			
				|  |  | -                })) ? ($asc ? $sort->reverse() : $sort) : false;
 | 
	
		
			
				|  |  | +                });
 | 
	
		
			
				|  |  |              default:
 | 
	
		
			
				|  |  | -                return ($sort = $this->sort("ksort")) ? ($asc ? $sort->reverse() : $sort) : false;
 | 
	
		
			
				|  |  | +                $sort = $this->sort("ksort");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if ($asc)
 | 
	
		
			
				|  |  | +                $sort = $sort->reverse();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            $repos->add($sort->all());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            return $repos;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          /**
 | 
	
	
		
			
				|  | @@ -221,94 +231,67 @@ namespace Gogs\API\Request {
 | 
	
		
			
				|  |  |          /** 
 | 
	
		
			
				|  |  |           * Get private repositories
 | 
	
		
			
				|  |  |           *
 | 
	
		
			
				|  |  | -         * @return \Gogs\Lib\Collection
 | 
	
		
			
				|  |  | +         * @return Repos
 | 
	
		
			
				|  |  |           */
 | 
	
		
			
				|  |  |          public function privates() {
 | 
	
		
			
				|  |  | -            return $this->filter(function(Repo $r) {
 | 
	
		
			
				|  |  | +            $repos = new Repos($this->url, $this->token, $this->owner);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            $repos->add($this->filter(function(Repo $r) {
 | 
	
		
			
				|  |  |                  return $r->private;
 | 
	
		
			
				|  |  | -            });
 | 
	
		
			
				|  |  | +            })->all());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            return $repos;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          /** 
 | 
	
		
			
				|  |  |           * Get public repositories
 | 
	
		
			
				|  |  |           *
 | 
	
		
			
				|  |  | -         * @return \Gogs\Lib\Collection
 | 
	
		
			
				|  |  | +         * @return Repos
 | 
	
		
			
				|  |  |           */
 | 
	
		
			
				|  |  |          public function publics() {
 | 
	
		
			
				|  |  | -            return $this->filter(function(Repo $r) {
 | 
	
		
			
				|  |  | +            $repos = new Repos($this->url, $this->token, $this->owner);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            $repos->add($this->filter(function(Repo $r) {
 | 
	
		
			
				|  |  |                  return !$r->private;
 | 
	
		
			
				|  |  | -            });
 | 
	
		
			
				|  |  | +            })->all());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            return $repos;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          /** 
 | 
	
		
			
				|  |  |           * Get personal repositories
 | 
	
		
			
				|  |  |           *
 | 
	
		
			
				|  |  | -         * @return \Gogs\Lib\Collection
 | 
	
		
			
				|  |  | +         * @return Repos
 | 
	
		
			
				|  |  |           */
 | 
	
		
			
				|  |  |          public function personals() {
 | 
	
		
			
				|  |  | +            $repos = new Repos($this->url, $this->token, $this->owner);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              if (empty($this->owner))
 | 
	
		
			
				|  |  | -                return new \Gogs\Lib\Collection();
 | 
	
		
			
				|  |  | +                return $repos;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            return $this->filter(function(Repo $r) {
 | 
	
		
			
				|  |  | +            $repos->add($this->filter(function(Repo $r) {
 | 
	
		
			
				|  |  |                  return $this->owner->username == $r->owner->username;
 | 
	
		
			
				|  |  | -            });
 | 
	
		
			
				|  |  | +            })->all());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            return $repos;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          /** 
 | 
	
		
			
				|  |  |           * Get repositories contributed to
 | 
	
		
			
				|  |  |           *
 | 
	
		
			
				|  |  | -         * @return \Gogs\Lib\Collection
 | 
	
		
			
				|  |  | +         * @return Repos
 | 
	
		
			
				|  |  |           */
 | 
	
		
			
				|  |  |          public function contributions() {
 | 
	
		
			
				|  |  | +            $repos = new Repos($this->url, $this->token, $this->owner);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              if (empty($this->owner))
 | 
	
		
			
				|  |  | -                return new \Gogs\Lib\Collection();
 | 
	
		
			
				|  |  | +                return $repos;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            return $this->filter(function(Repo $r) {
 | 
	
		
			
				|  |  | +            $repos->add($this->filter(function(Repo $r) {
 | 
	
		
			
				|  |  |                  return $this->owner->username != $r->owner->username;
 | 
	
		
			
				|  |  | -            });
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        /** 
 | 
	
		
			
				|  |  | -         * Get personal private repositories
 | 
	
		
			
				|  |  | -         *
 | 
	
		
			
				|  |  | -         * @return \Gogs\Lib\Collection
 | 
	
		
			
				|  |  | -         */
 | 
	
		
			
				|  |  | -        public function personals_privates() {
 | 
	
		
			
				|  |  | -            return $this->personals()->filter(function(Repo $r) {
 | 
	
		
			
				|  |  | -                return $r->private;
 | 
	
		
			
				|  |  | -            });
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        /** 
 | 
	
		
			
				|  |  | -         * Get personal public repositories
 | 
	
		
			
				|  |  | -         *
 | 
	
		
			
				|  |  | -         * @return \Gogs\Lib\Collection
 | 
	
		
			
				|  |  | -         */
 | 
	
		
			
				|  |  | -        public function personals_publics() {
 | 
	
		
			
				|  |  | -            return $this->personals()->filter(function(Repo $r) {
 | 
	
		
			
				|  |  | -                return !$r->private;
 | 
	
		
			
				|  |  | -            });
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | +            })->all());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        /** 
 | 
	
		
			
				|  |  | -         * Get private contributions
 | 
	
		
			
				|  |  | -         *
 | 
	
		
			
				|  |  | -         * @return \Gogs\Lib\Collection
 | 
	
		
			
				|  |  | -         */
 | 
	
		
			
				|  |  | -        public function contributions_privates() {
 | 
	
		
			
				|  |  | -            return $this->contributions()->filter(function(Repo $r) {
 | 
	
		
			
				|  |  | -                return $r->private;
 | 
	
		
			
				|  |  | -            });
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        /** 
 | 
	
		
			
				|  |  | -         * Get public contributions
 | 
	
		
			
				|  |  | -         *
 | 
	
		
			
				|  |  | -         * @return \Gogs\Lib\Collection
 | 
	
		
			
				|  |  | -         */
 | 
	
		
			
				|  |  | -        public function contributions_publics() {
 | 
	
		
			
				|  |  | -            return $this->contributions()->filter(function(Repo $r) {
 | 
	
		
			
				|  |  | -                return !$r->private;
 | 
	
		
			
				|  |  | -            });
 | 
	
		
			
				|  |  | +            return $repos;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 |