Skip to content

Add PSR12 and fix outstanding issues #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Linux/unix/MacOs line endings
* text eol=lf
5 changes: 4 additions & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@ jobs:
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run phpcs
run: composer run-script phpcs src

- name: Run phpunit
run: ./vendor/bin/phpunit
run: composer run-script test
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"guzzlehttp/guzzle": "^7.0.1"
},
"require-dev": {
"phpunit/phpunit": "^8.5"
"phpunit/phpunit": "^8.5",
"squizlabs/php_codesniffer": "*"
},
"autoload": {
"psr-4": {
Expand All @@ -28,6 +29,8 @@
}
},
"scripts": {
"test": "phpunit"
"test": "phpunit",
"phpcs": "phpcs",
"phpcbf": "phpcbf"
}
}
53 changes: 52 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<ruleset name="CodeMash.Php code standarts">
<description>The coding standard for CodeMash PHP SDK project</description>
<arg name="extensions" value="php"/>
<arg value="p"/> <!-- progress -->
<rule ref="PSR12">
</rule>
</ruleset>
54 changes: 33 additions & 21 deletions src/CodemashDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,17 @@ public function updateOne(array $params): array
{
$params = CodemashDbParams::prepUpdateOneParams($params);

$response = $this->client->request('PATCH', $this->uriPrefix . $params['collectionName'] . '/' . $params['id'], [
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'body' => toJson($params),
]);
$response = $this->client->request(
'PATCH',
$this->uriPrefix . $params['collectionName'] . '/' . $params['id'],
[
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'body' => toJson($params),
]
);

return $response['result'];
}
Expand Down Expand Up @@ -236,13 +240,17 @@ public function deleteOne(array $params): array
{
$params = CodemashDbParams::prepDeleteOneParams($params);

$response = $this->client->request('DELETE', $this->uriPrefix . $params['collectionName'] . '/' . $params['id'], [
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'body' => toJson($params),
]);
$response = $this->client->request(
'DELETE',
$this->uriPrefix . $params['collectionName'] . '/' . $params['id'],
[
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'body' => toJson($params),
]
);

return $response['result'];
}
Expand Down Expand Up @@ -312,13 +320,17 @@ public function getTaxonomyTerms(array $params): array
{
$params = CodemashDbParams::prepGetTaxonomyTerms($params);

$response = $this->client->request('GET', $this->uriPrefix . '/taxonomies/' . $params['taxonomyName'] . '/terms', [
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'body' => toJson($params),
]);
$response = $this->client->request(
'GET',
$this->uriPrefix . '/taxonomies/' . $params['taxonomyName'] . '/terms',
[
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'body' => toJson($params),
]
);

return $response['result'];
}
Expand Down
6 changes: 5 additions & 1 deletion src/CodemashFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ public function uploadRecordFile(array $params): array

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

$response = $this->client->request('POST', $this->uriPrefix . 'db/' . $params['collectionName'] . '/files', $options);
$response = $this->client->request(
'POST',
$this->uriPrefix . 'db/' . $params['collectionName'] . '/files',
$options
);

return $response['result'];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Params/CodemashDbParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public static function prepGetAggregateParams(array $params): array
return [
'collectionName' => $params['collectionName'],
'id' => $params['id'] ?? null,
'pipeline' => ! empty ($params['pipeline']) ? array_map('toJson', $params['pipeline']) : null,
'pipeline' => ! empty($params['pipeline']) ? array_map('toJson', $params['pipeline']) : null,
'tokens' => ! empty($params['tokens']) ? (object) ($params['tokens']) : null,
];
}
Expand Down