Skip to content

Commit c34969b

Browse files
authored
Merge pull request #3 from gloomy/master
Add PSR12 and fix outstanding issues
2 parents 8199941 + 7cdf32f commit c34969b

File tree

8 files changed

+110
-27
lines changed

8 files changed

+110
-27
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Linux/unix/MacOs line endings
2+
* text eol=lf

.github/workflows/php.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,8 @@ jobs:
4141
if: steps.composer-cache.outputs.cache-hit != 'true'
4242
run: composer install --prefer-dist --no-progress --no-suggest
4343

44+
- name: Run phpcs
45+
run: composer run-script phpcs src
46+
4447
- name: Run phpunit
45-
run: ./vendor/bin/phpunit
48+
run: composer run-script test

composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"guzzlehttp/guzzle": "^7.0.1"
1212
},
1313
"require-dev": {
14-
"phpunit/phpunit": "^8.5"
14+
"phpunit/phpunit": "^8.5",
15+
"squizlabs/php_codesniffer": "*"
1516
},
1617
"autoload": {
1718
"psr-4": {
@@ -28,6 +29,8 @@
2829
}
2930
},
3031
"scripts": {
31-
"test": "phpunit"
32+
"test": "phpunit",
33+
"phpcs": "phpcs",
34+
"phpcbf": "phpcbf"
3235
}
3336
}

composer.lock

Lines changed: 52 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpcs.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="CodeMash.Php code standarts">
3+
<description>The coding standard for CodeMash PHP SDK project</description>
4+
<arg name="extensions" value="php"/>
5+
<arg value="p"/> <!-- progress -->
6+
<rule ref="PSR12">
7+
</rule>
8+
</ruleset>

src/CodemashDb.php

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,17 @@ public function updateOne(array $params): array
179179
{
180180
$params = CodemashDbParams::prepUpdateOneParams($params);
181181

182-
$response = $this->client->request('PATCH', $this->uriPrefix . $params['collectionName'] . '/' . $params['id'], [
183-
'headers' => [
184-
'Accept' => 'application/json',
185-
'Content-Type' => 'application/json',
186-
],
187-
'body' => toJson($params),
188-
]);
182+
$response = $this->client->request(
183+
'PATCH',
184+
$this->uriPrefix . $params['collectionName'] . '/' . $params['id'],
185+
[
186+
'headers' => [
187+
'Accept' => 'application/json',
188+
'Content-Type' => 'application/json',
189+
],
190+
'body' => toJson($params),
191+
]
192+
);
189193

190194
return $response['result'];
191195
}
@@ -236,13 +240,17 @@ public function deleteOne(array $params): array
236240
{
237241
$params = CodemashDbParams::prepDeleteOneParams($params);
238242

239-
$response = $this->client->request('DELETE', $this->uriPrefix . $params['collectionName'] . '/' . $params['id'], [
240-
'headers' => [
241-
'Accept' => 'application/json',
242-
'Content-Type' => 'application/json',
243-
],
244-
'body' => toJson($params),
245-
]);
243+
$response = $this->client->request(
244+
'DELETE',
245+
$this->uriPrefix . $params['collectionName'] . '/' . $params['id'],
246+
[
247+
'headers' => [
248+
'Accept' => 'application/json',
249+
'Content-Type' => 'application/json',
250+
],
251+
'body' => toJson($params),
252+
]
253+
);
246254

247255
return $response['result'];
248256
}
@@ -312,13 +320,17 @@ public function getTaxonomyTerms(array $params): array
312320
{
313321
$params = CodemashDbParams::prepGetTaxonomyTerms($params);
314322

315-
$response = $this->client->request('GET', $this->uriPrefix . '/taxonomies/' . $params['taxonomyName'] . '/terms', [
316-
'headers' => [
317-
'Accept' => 'application/json',
318-
'Content-Type' => 'application/json',
319-
],
320-
'body' => toJson($params),
321-
]);
323+
$response = $this->client->request(
324+
'GET',
325+
$this->uriPrefix . '/taxonomies/' . $params['taxonomyName'] . '/terms',
326+
[
327+
'headers' => [
328+
'Accept' => 'application/json',
329+
'Content-Type' => 'application/json',
330+
],
331+
'body' => toJson($params),
332+
]
333+
);
322334

323335
return $response['result'];
324336
}

src/CodemashFile.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ public function uploadRecordFile(array $params): array
9797

9898
$options = $this->prepUploadFileOptions($params);
9999

100-
$response = $this->client->request('POST', $this->uriPrefix . 'db/' . $params['collectionName'] . '/files', $options);
100+
$response = $this->client->request(
101+
'POST',
102+
$this->uriPrefix . 'db/' . $params['collectionName'] . '/files',
103+
$options
104+
);
101105

102106
return $response['result'];
103107
}

src/Params/CodemashDbParams.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public static function prepGetAggregateParams(array $params): array
144144
return [
145145
'collectionName' => $params['collectionName'],
146146
'id' => $params['id'] ?? null,
147-
'pipeline' => ! empty ($params['pipeline']) ? array_map('toJson', $params['pipeline']) : null,
147+
'pipeline' => ! empty($params['pipeline']) ? array_map('toJson', $params['pipeline']) : null,
148148
'tokens' => ! empty($params['tokens']) ? (object) ($params['tokens']) : null,
149149
];
150150
}

0 commit comments

Comments
 (0)