| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Manavo\DoneDone; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 5 |  |  | class Project | 
            
                                                                        
                            
            
                                    
            
            
                | 6 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 8 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 9 |  |  |      * @var Client | 
            
                                                                        
                            
            
                                    
            
            
                | 10 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 11 |  |  |     private $client; | 
            
                                                                        
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 13 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 14 |  |  |      * @var int | 
            
                                                                        
                            
            
                                    
            
            
                | 15 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  |     private $id; | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |      * @param Client $client | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |      * @param int    $id | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 | 63 |  |     function __construct($client, $id) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 | 63 |  |         $this->client = $client; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 | 63 |  |         $this->id = $id; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 26 | 63 |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |      * Get the details of this project | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |      * @return array | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     public function get() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         return $this->client->get(sprintf('projects/%d', $this->id)); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 36 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |      * Get all the people associated with this project | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |      * @return array | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 | 3 |  |     public function people() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 | 3 |  |         return $this->client->get('projects/' . $this->id . '/people'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 46 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |      * Get all the issues associated with this project | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |      * @return array | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 3 |  |     public function issues() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 | 3 |  |         return $this->client->get('projects/' . $this->id . '/issues/all'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 56 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |      * @param int $id | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |      * @return Issue | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 | 27 |  |     public function issue($id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 | 27 |  |         return new Issue($this->client, $this->id, $id); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 66 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |      * Get all the active issues associated with this project | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |      * @return array | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 | 3 |  |     public function activeIssues() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 | 3 |  |         return $this->client->get( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 3 |  |             'projects/' . $this->id . '/issues/all_active' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 | 3 |  |         ); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 78 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  |      * Get all the closed and fixed issues associated with this project | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |      * @return array | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 | 3 |  |     public function closedAndFixedIssues() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 | 3 |  |         return $this->client->get( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 | 3 |  |             'projects/' . $this->id . '/issues/all_closed_and_fixed' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 | 3 |  |         ); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 90 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  |      * Get all the issues by a filter associated with this project | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  |      * @param int $filter | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  |      * @return array | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 | 3 |  |     public function issuesByFilter($filter) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 | 3 |  |         return $this->client->get( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 | 3 |  |             sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 | 3 |  |                 'projects/%d/issues/by_custom_filter/%d', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 | 3 |  |                 $this->id, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |                 $filter | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 | 3 |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 | 3 |  |         ); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 108 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 110 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 111 |  |  |      * Get all the issues which are waiting on you, and are associated with | 
            
                                                                        
                            
            
                                    
            
            
                | 112 |  |  |      * this project | 
            
                                                                        
                            
            
                                    
            
            
                | 113 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 114 |  |  |      * @return array | 
            
                                                                        
                            
            
                                    
            
            
                | 115 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 | 3 |  |     public function issuesWaitingOnYou() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 | 3 |  |         return $this->client->get( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 | 3 |  |             sprintf('projects/%d/issues/waiting_on_you', $this->id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 | 3 |  |         ); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 121 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 122 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 123 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 124 |  |  |      * Get all the issues which are waiting on them | 
            
                                                                        
                            
            
                                    
            
            
                | 125 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 126 |  |  |      * @return array | 
            
                                                                        
                            
            
                                    
            
            
                | 127 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 | 3 |  |     public function issuesWaitingOnThem() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 | 3 |  |         return $this->client->get( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 | 3 |  |             sprintf('projects/%d/issues/waiting_on_them', $this->id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 | 3 |  |         ); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 133 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 134 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 135 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 136 |  |  |      * Get release builds of this project | 
            
                                                                        
                            
            
                                    
            
            
                | 137 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 138 |  |  |      * @return array | 
            
                                                                        
                            
            
                                    
            
            
                | 139 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 | 3 |  |     public function releaseBuilds() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 | 3 |  |         return $this->client->get('projects/' . $this->id . '/release_builds'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 143 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 144 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 145 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 146 |  |  |      * Get release builds of this project | 
            
                                                                        
                            
            
                                    
            
            
                | 147 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 148 |  |  |      * @return ReleaseBuildInfo | 
            
                                                                        
                            
            
                                    
            
            
                | 149 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |     public function releaseBuildInfo() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |         return new ReleaseBuildInfo($this->client->get('projects/' . $this->id . '/release_builds/info')); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 153 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 154 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 155 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 156 |  |  |      * Get filters of this project | 
            
                                                                        
                            
            
                                    
            
            
                | 157 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 158 |  |  |      * @return array | 
            
                                                                        
                            
            
                                    
            
            
                | 159 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 | 3 |  |     public function filters() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 | 3 |  |         return $this->client->get('projects/' . $this->id . '/custom_filters'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 163 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 164 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 165 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 166 |  |  |      * Add a new issue to the project | 
            
                                                                        
                            
            
                                    
            
            
                | 167 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 168 |  |  |      * @param Issue $issue | 
            
                                                                        
                            
            
                                    
            
            
                | 169 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 170 |  |  |      * @return array | 
            
                                                                        
                            
            
                                    
            
            
                | 171 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 | 3 |  |     public function addIssue($issue) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 | 3 |  |         return $this->client->post( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 | 3 |  |             'projects/' . $this->id . '/issues', $issue->toArray() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 | 3 |  |         ); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 177 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 178 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 179 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 180 |  |  |      * Create a new release build for the project | 
            
                                                                        
                            
            
                                    
            
            
                | 181 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 182 |  |  |      * @param ReleaseBuild $releaseBuild | 
            
                                                                        
                            
            
                                    
            
            
                | 183 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 184 |  |  |      * @return array | 
            
                                                                        
                            
            
                                    
            
            
                | 185 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 | 3 |  |     public function createReleaseBuild($releaseBuild) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 | 3 |  |         return $this->client->post( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 | 3 |  |             sprintf('projects/%d/release_builds', $this->id), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 | 3 |  |             $releaseBuild->toArray() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 | 3 |  |         ); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 192 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 193 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 194 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 195 |  |  |  | 
            
                        
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.