Skip to content

Commit 6b037a1

Browse files
committed
Use OptionsResolver in Branch & Project models
1 parent 016c93c commit 6b037a1

File tree

2 files changed

+51
-37
lines changed

2 files changed

+51
-37
lines changed

lib/Gitlab/Model/Branch.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php namespace Gitlab\Model;
22

3+
use Gitlab\Api\Projects;
34
use Gitlab\Client;
4-
use Gitlab\Api\AbstractApi as Api;
55

66
/**
77
* Class Branch
@@ -95,13 +95,15 @@ public function delete()
9595
}
9696

9797
/**
98-
* @param int $page
99-
* @param int $per_page
98+
* @param array $parameters
99+
*
100+
* @see Projects::commits for available parameters.
101+
*
100102
* @return Commit[]
101103
*/
102-
public function commits($page = 1, $per_page = Api::PER_PAGE)
104+
public function commits(array $parameters = [])
103105
{
104-
return $this->project->commits($page, $per_page, $this->name);
106+
return $this->project->commits($parameters);
105107
}
106108

107109
/**

lib/Gitlab/Model/Project.php

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php namespace Gitlab\Model;
22

3-
use Gitlab\Api\MergeRequests;
3+
use Gitlab\Api\Projects;
4+
use Gitlab\Api\Repositories;
45
use Gitlab\Client;
5-
use Gitlab\Api\AbstractApi as Api;
66

77
/**
88
* Class Project
@@ -235,13 +235,15 @@ public function removeMember($user_id)
235235
}
236236

237237
/**
238-
* @param int $page
239-
* @param int $per_page
238+
* @param array $parameters
239+
*
240+
* @see Projects::hooks() for available parameters.
241+
*
240242
* @return ProjectHook[]
241243
*/
242-
public function hooks($page = 1, $per_page = Api::PER_PAGE)
244+
public function hooks(array $parameters = [])
243245
{
244-
$data = $this->client->projects()->hooks($this->id, $page, $per_page);
246+
$data = $this->client->projects()->hooks($this->id, $parameters);
245247

246248
$hooks = array();
247249
foreach ($data as $hook) {
@@ -449,14 +451,15 @@ public function tags()
449451
}
450452

451453
/**
452-
* @param int $page
453-
* @param int $per_page
454-
* @param string $ref_name
454+
* @param array $parameters
455+
*
456+
* @see Repositories::commits() for available parameters.
457+
*
455458
* @return Commit[]
456459
*/
457-
public function commits($page = 0, $per_page = Api::PER_PAGE, $ref_name = null)
460+
public function commits(array $parameters = [])
458461
{
459-
$data = $this->client->repositories()->commits($this->id, $page, $per_page, $ref_name);
462+
$data = $this->client->repositories()->commits($this->id, $parameters);
460463

461464
$commits = array();
462465
foreach ($data as $commit) {
@@ -479,13 +482,15 @@ public function commit($sha)
479482

480483
/**
481484
* @param string $ref
482-
* @param int $page
483-
* @param int $per_page
485+
* @param array $parameters
486+
*
487+
* @see Repositories::commitComments() for available parameters.
488+
*
484489
* @return Commit[]
485490
*/
486-
public function commitComments($ref, $page = 0, $per_page = Api::PER_PAGE)
491+
public function commitComments($ref, array $parameters = [])
487492
{
488-
$data = $this->client->repositories()->commitComments($this->id, $ref, $page, $per_page);
493+
$data = $this->client->repositories()->commitComments($this->id, $ref, $parameters);
489494

490495
$comments = array();
491496
foreach ($data as $comment) {
@@ -614,13 +619,15 @@ public function deleteFile($file_path, $branch_name, $commit_message, $author_em
614619
}
615620

616621
/**
617-
* @param int $page
618-
* @param int $per_page
622+
* @param array $parameters
623+
*
624+
* @see Projects::events() for available parameters.
625+
*
619626
* @return Event[]
620627
*/
621-
public function events($page = 1, $per_page = Api::PER_PAGE)
628+
public function events(array $parameters = [])
622629
{
623-
$data = $this->client->projects()->events($this->id, $page, $per_page);
630+
$data = $this->client->projects()->events($this->id, $parameters);
624631

625632
$events = array();
626633
foreach ($data as $event) {
@@ -631,14 +638,15 @@ public function events($page = 1, $per_page = Api::PER_PAGE)
631638
}
632639

633640
/**
634-
* @param int $page
635-
* @param int $per_page
636-
* @param string $state
641+
* @param array $parameters
642+
*
643+
* @see MergeRequests::all() for available parameters.
644+
*
637645
* @return MergeRequest[]
638646
*/
639-
public function mergeRequests($page = 1, $per_page = Api::PER_PAGE, $state = MergeRequests::STATE_ALL)
647+
public function mergeRequests(array $parameters = [])
640648
{
641-
$data = $this->client->mergeRequests()->$state($this->id, $page, $per_page);
649+
$data = $this->client->mergeRequests()->all($this->id, $parameters);
642650

643651
$mrs = array();
644652
foreach ($data as $mr) {
@@ -720,13 +728,15 @@ public function mergeMergeRequest($id)
720728
}
721729

722730
/**
723-
* @param int $page
724-
* @param int $per_page
731+
* @param array $parameters
732+
*
733+
* @see Issues::all() for available parameters.
734+
*
725735
* @return Issue[]
726736
*/
727-
public function issues($page = 1, $per_page = Api::PER_PAGE)
737+
public function issues(array $parameters = [])
728738
{
729-
$data = $this->client->issues()->all($this->id, $page, $per_page);
739+
$data = $this->client->issues()->all($this->id, $parameters);
730740

731741
$issues = array();
732742
foreach ($data as $issue) {
@@ -796,13 +806,15 @@ public function openIssue($id)
796806
}
797807

798808
/**
799-
* @param int $page
800-
* @param int $per_page
809+
* @param array $parameters
810+
*
811+
* @see Milestones::all() for available parameters.
812+
*
801813
* @return Milestone[]
802814
*/
803-
public function milestones($page = 1, $per_page = Api::PER_PAGE)
815+
public function milestones(array $parameters = [])
804816
{
805-
$data = $this->client->milestones()->all($this->id, $page, $per_page);
817+
$data = $this->client->milestones()->all($this->id, $parameters);
806818

807819
$milestones = array();
808820
foreach ($data as $milestone) {

0 commit comments

Comments
 (0)