Skip to content

Commit df9ddc3

Browse files
authored
Merge pull request #226 from fbourigault/psr-2
Update coding standards to PSR-2.
2 parents a73719b + 2d5e5e3 commit df9ddc3

15 files changed

+78
-72
lines changed

.styleci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
preset: psr2

lib/Gitlab/Api/AbstractApi.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,15 @@ protected function createOptionsResolver()
203203
$resolver = new OptionsResolver();
204204
$resolver->setDefined('page')
205205
->setAllowedTypes('page', 'int')
206-
->setAllowedValues('page', function ($value) { return $value > 0; })
206+
->setAllowedValues('page', function ($value) {
207+
return $value > 0;
208+
})
207209
;
208210
$resolver->setDefined('per_page')
209211
->setAllowedTypes('per_page', 'int')
210-
->setAllowedValues('per_page', function ($value) { return $value > 0 && $value <= 100; })
212+
->setAllowedValues('per_page', function ($value) {
213+
return $value > 0 && $value <= 100;
214+
})
211215
;
212216
$resolver->setDefined('sort')
213217
->setAllowedValues('sort', ['asc', 'desc'])
@@ -218,7 +222,6 @@ protected function createOptionsResolver()
218222

219223
private function preparePath($path, array $parameters = [])
220224
{
221-
222225
if (count($parameters) > 0) {
223226
$path .= '?'.QueryStringBuilder::build($parameters);
224227
}

lib/Gitlab/Api/Projects.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,17 @@ public function remove($project_id)
135135
* @param int $project_id
136136
* @return mixed
137137
*/
138-
public function archive($project_id){
138+
public function archive($project_id)
139+
{
139140
return $this->post("projects/".$this->encodePath($project_id)."/archive");
140141
}
141142

142143
/**
143144
* @param int $project_id
144145
* @return mixed
145146
*/
146-
public function unarchive($project_id){
147+
public function unarchive($project_id)
148+
{
147149
return $this->post("projects/".$this->encodePath($project_id)."/unarchive");
148150
}
149151

lib/Gitlab/Api/Repositories.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,13 @@ public function createTag($project_id, $name, $ref, $message = null)
102102
*
103103
* @return mixed
104104
*/
105-
public function createRelease( $project_id, $tag_name, $description ) {
106-
return $this->post( $this->getProjectPath( $project_id, 'repository/tags/' . $this->encodeBranch( $tag_name ) . '/release' ), array(
105+
public function createRelease($project_id, $tag_name, $description)
106+
{
107+
return $this->post($this->getProjectPath($project_id, 'repository/tags/' . $this->encodeBranch($tag_name) . '/release'), array(
107108
'id' => $project_id,
108109
'tag_name' => $tag_name,
109110
'description' => $description
110-
) );
111+
));
111112
}
112113

113114
/**
@@ -117,12 +118,13 @@ public function createRelease( $project_id, $tag_name, $description ) {
117118
*
118119
* @return mixed
119120
*/
120-
public function updateRelease( $project_id, $tag_name, $description ) {
121-
return $this->put( $this->getProjectPath( $project_id, 'repository/tags/' . $this->encodeBranch( $tag_name ) . '/release' ), array(
121+
public function updateRelease($project_id, $tag_name, $description)
122+
{
123+
return $this->put($this->getProjectPath($project_id, 'repository/tags/' . $this->encodeBranch($tag_name) . '/release'), array(
122124
'id' => $project_id,
123125
'tag_name' => $tag_name,
124126
'description' => $description
125-
) );
127+
));
126128
}
127129

128130
/**

lib/Gitlab/Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function jobs()
162162
*/
163163
public function mergeRequests()
164164
{
165-
return new Api\MergeRequests($this);
165+
return new Api\MergeRequests($this);
166166
}
167167

168168
/**
@@ -194,7 +194,7 @@ public function projects()
194194
*/
195195
public function repositories()
196196
{
197-
return new Api\Repositories($this);
197+
return new Api\Repositories($this);
198198
}
199199

200200
/**

lib/Gitlab/Exception/ErrorException.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@
77
*/
88
class ErrorException extends \ErrorException
99
{
10-
1110
}

lib/Gitlab/Exception/InvalidArgumentException.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@
77
*/
88
class InvalidArgumentException extends \InvalidArgumentException
99
{
10-
1110
}

lib/Gitlab/Exception/RuntimeException.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@
77
*/
88
class RuntimeException extends \RuntimeException
99
{
10-
1110
}

lib/Gitlab/Exception/ValidationFailedException.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@
77
*/
88
class ValidationFailedException extends ErrorException
99
{
10-
1110
}

lib/Gitlab/Model/Group.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,8 @@ public function removeMember($user_id)
131131
*/
132132
public function projects()
133133
{
134-
135134
$data = $this->client->groups()->projects($this->id);
136135

137-
return Group::fromArray($this->getClient(),$data);
136+
return Group::fromArray($this->getClient(), $data);
138137
}
139138
}

lib/Gitlab/Model/Project.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,5 +1124,4 @@ public function job($job_id)
11241124

11251125
return Job::fromArray($this->getClient(), $this, $data);
11261126
}
1127-
11281127
}

test/Gitlab/Tests/Api/RepositoriesTest.php

Lines changed: 49 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -167,53 +167,55 @@ public function shouldCreateTag()
167167
$this->assertEquals($expectedArray, $api->createTag(1, '1.0', 'abcd1234', '1.0 release'));
168168
}
169169

170-
/**
171-
* @test
172-
*/
173-
public function shouldCreateRelease() {
174-
$project_id = 1;
175-
$tagName = 'sometag';
176-
$description = '1.0 release';
177-
178-
$expectedArray = array( 'name' => $tagName );
179-
180-
$api = $this->getApiMock();
181-
$api->expects( $this->once())
182-
->method('post')
183-
->with( 'projects/' . $project_id . '/repository/tags/' . $tagName . '/release', array(
184-
'id' => $project_id,
185-
'tag_name' => $tagName,
186-
'description' => $description
187-
))
188-
->will($this->returnValue($expectedArray))
189-
;
190-
191-
$this->assertEquals( $expectedArray, $api->createRelease( $project_id, $tagName, $description ) );
192-
}
193-
194-
/**
195-
* @test
196-
*/
197-
public function shouldUpdateRelease() {
198-
$project_id = 1;
199-
$tagName = 'sometag';
200-
$description = '1.0 release';
201-
202-
$expectedArray = array( 'description' => $tagName );
203-
204-
$api = $this->getApiMock();
205-
$api->expects( $this->once())
206-
->method('put')
207-
->with( 'projects/' . $project_id . '/repository/tags/' . $tagName . '/release', array(
208-
'id' => $project_id,
209-
'tag_name' => $tagName,
210-
'description' => $description
211-
))
212-
->will($this->returnValue($expectedArray))
213-
;
214-
215-
$this->assertEquals( $expectedArray, $api->updateRelease( $project_id, $tagName, $description ) );
216-
}
170+
/**
171+
* @test
172+
*/
173+
public function shouldCreateRelease()
174+
{
175+
$project_id = 1;
176+
$tagName = 'sometag';
177+
$description = '1.0 release';
178+
179+
$expectedArray = array( 'name' => $tagName );
180+
181+
$api = $this->getApiMock();
182+
$api->expects($this->once())
183+
->method('post')
184+
->with('projects/' . $project_id . '/repository/tags/' . $tagName . '/release', array(
185+
'id' => $project_id,
186+
'tag_name' => $tagName,
187+
'description' => $description
188+
))
189+
->will($this->returnValue($expectedArray))
190+
;
191+
192+
$this->assertEquals($expectedArray, $api->createRelease($project_id, $tagName, $description));
193+
}
194+
195+
/**
196+
* @test
197+
*/
198+
public function shouldUpdateRelease()
199+
{
200+
$project_id = 1;
201+
$tagName = 'sometag';
202+
$description = '1.0 release';
203+
204+
$expectedArray = array( 'description' => $tagName );
205+
206+
$api = $this->getApiMock();
207+
$api->expects($this->once())
208+
->method('put')
209+
->with('projects/' . $project_id . '/repository/tags/' . $tagName . '/release', array(
210+
'id' => $project_id,
211+
'tag_name' => $tagName,
212+
'description' => $description
213+
))
214+
->will($this->returnValue($expectedArray))
215+
;
216+
217+
$this->assertEquals($expectedArray, $api->updateRelease($project_id, $tagName, $description));
218+
}
217219

218220
/**
219221
* @test

test/Gitlab/Tests/HttpClient/BuilderTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
namespace Gitlab\Tests\HttpClient;
4+
45
use Gitlab\HttpClient\Builder;
56
use Http\Client\Common\HttpMethodsClient;
67
use Http\Client\Common\Plugin;

test/Gitlab/Tests/HttpClient/Plugin/ApiVersionTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
class ApiVersionTest extends \PHPUnit_Framework_TestCase
1212
{
13-
1413
public function testCallNextCallback()
1514
{
1615
$request = new Request('GET', '');
@@ -27,7 +26,8 @@ public function testCallNextCallback()
2726
->willReturn($promise)
2827
;
2928

30-
$this->assertEquals($promise, $plugin->handleRequest($request, [$callback, 'next'], function () {}));
29+
$this->assertEquals($promise, $plugin->handleRequest($request, [$callback, 'next'], function () {
30+
}));
3131
}
3232

3333
public function testPrefixRequestPath()
@@ -45,7 +45,8 @@ public function testPrefixRequestPath()
4545
->with($expected)
4646
;
4747

48-
$plugin->handleRequest($request, [$callback, 'next'], function () {});
48+
$plugin->handleRequest($request, [$callback, 'next'], function () {
49+
});
4950
}
5051

5152
public function testNoPrefixingRequired()
@@ -62,6 +63,7 @@ public function testNoPrefixingRequired()
6263
->with($request)
6364
;
6465

65-
$plugin->handleRequest($request, [$callback, 'next'], function () {});
66+
$plugin->handleRequest($request, [$callback, 'next'], function () {
67+
});
6668
}
6769
}

test/Gitlab/Tests/ResultPagerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
class ResultPagerTest extends \PHPUnit_Framework_TestCase
1414
{
15-
1615
public function testFetch()
1716
{
1817
$client = $this->getMockBuilder(Client::class)

0 commit comments

Comments
 (0)