1- <?php
2-
3- namespace Gitlab \Model ;
1+ <?php namespace Gitlab \Model ;
42
53use Gitlab \Client ;
64use Gitlab \Api \AbstractApi as Api ;
75
86class Branch extends AbstractModel
97{
10- protected static $ _properties = array (
8+ /**
9+ * @var array
10+ */
11+ protected static $ properties = array (
1112 'name ' ,
1213 'commit ' ,
1314 'project ' ,
1415 'protected '
1516 );
1617
18+ /**
19+ * @param Client $client
20+ * @param Project $project
21+ * @param array $data
22+ * @return Branch
23+ */
1724 public static function fromArray (Client $ client , Project $ project , array $ data )
1825 {
1926 $ branch = new static ($ project , $ data ['name ' ], $ client );
@@ -25,6 +32,11 @@ public static function fromArray(Client $client, Project $project, array $data)
2532 return $ branch ->hydrate ($ data );
2633 }
2734
35+ /**
36+ * @param Project $project
37+ * @param string $name
38+ * @param Client $client
39+ */
2840 public function __construct (Project $ project , $ name = null , Client $ client = null )
2941 {
3042 $ this ->setClient ($ client );
@@ -33,53 +45,87 @@ public function __construct(Project $project, $name = null, Client $client = nul
3345 $ this ->name = $ name ;
3446 }
3547
48+ /**
49+ * @return Branch
50+ */
3651 public function show ()
3752 {
3853 $ data = $ this ->api ('repositories ' )->branch ($ this ->project ->id , $ this ->name );
3954
40- return Branch ::fromArray ($ this ->getClient (), $ this ->project , $ data );
55+ return static ::fromArray ($ this ->getClient (), $ this ->project , $ data );
4156 }
4257
58+ /**
59+ * @return Branch
60+ */
4361 public function protect ()
4462 {
4563 $ data = $ this ->api ('repositories ' )->protectBranch ($ this ->project ->id , $ this ->name );
4664
47- return Branch ::fromArray ($ this ->getClient (), $ this ->project , $ data );
65+ return static ::fromArray ($ this ->getClient (), $ this ->project , $ data );
4866 }
4967
68+ /**
69+ * @return Branch
70+ */
5071 public function unprotect ()
5172 {
5273 $ data = $ this ->api ('repositories ' )->unprotectBranch ($ this ->project ->id , $ this ->name );
5374
54- return Branch ::fromArray ($ this ->getClient (), $ this ->project , $ data );
75+ return static ::fromArray ($ this ->getClient (), $ this ->project , $ data );
5576 }
5677
78+ /**
79+ * @return bool
80+ */
5781 public function delete ()
5882 {
5983 $ this ->api ('repositories ' )->deleteBranch ($ this ->project ->id , $ this ->name );
6084
6185 return true ;
6286 }
6387
88+ /**
89+ * @param int $page
90+ * @param int $per_page
91+ * @return Commit[]
92+ */
6493 public function commits ($ page = 1 , $ per_page = Api::PER_PAGE )
6594 {
6695 return $ this ->project ->commits ($ page , $ per_page , $ this ->name );
6796 }
6897
98+ /**
99+ * @param string $file_path
100+ * @param string $content
101+ * @param string $commit_message
102+ * @return File
103+ */
69104 public function createFile ($ file_path , $ content , $ commit_message )
70105 {
71106 $ data = $ this ->api ('repositories ' )->createFile ($ this ->project ->id , $ file_path , $ content , $ this ->name , $ commit_message );
72107
73108 return File::fromArray ($ this ->getClient (), $ this , $ data );
74109 }
75110
111+ /**
112+ * @param string $file_path
113+ * @param string $content
114+ * @param string $commit_message
115+ * @return File
116+ */
76117 public function updateFile ($ file_path , $ content , $ commit_message )
77118 {
78119 $ data = $ this ->api ('repositories ' )->updateFile ($ this ->project ->id , $ file_path , $ content , $ this ->name , $ commit_message );
79120
80121 return File::fromArray ($ this ->getClient (), $ this , $ data );
81122 }
82123
124+ /**
125+ * @param string $file_path
126+ * @param string $commit_message
127+ * @return bool
128+ */
83129 public function deleteFile ($ file_path , $ commit_message )
84130 {
85131 $ this ->api ('repositories ' )->deleteFile ($ this ->project ->id , $ file_path , $ this ->name , $ commit_message );
0 commit comments