Skip to content
Open
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
63 changes: 63 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Unit Tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
provide_php_versions_json:
runs-on: ubuntu-latest

steps:
# git clone + use PHP + composer install
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: 8.0

- run: composer install --no-progress --ansi

- run: vendor/bin/easy-ci php-versions-json

- id: output_data
run: echo "::set-output name=matrix::$(vendor/bin/easy-ci php-versions-json)"

outputs:
matrix: ${{ steps.output_data.outputs.matrix }}

unit_tests:
needs: provide_php_versions_json

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php: ${{ fromJson(needs.provide_php_versions_json.outputs.matrix) }}

name: PHP ${{ matrix.php }} tests

steps:
- uses: actions/checkout@v2

- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none

# composer install cache - https://github.com/ramsey/composer-install

- if: "matrix.php >= 8"
uses: "ramsey/composer-install@v1"
with:
composer-options: "--ignore-platform-req php"


- name: Run phplint - Syntax check
run: ./vendor/bin/phplint -c ci/phplint.yml lib
- name: Run phpcs - PSR2 check
run: ./vendor/bin/phpcs --standard=ci/phpbcs.xml lib
- name: Run PHPUnit tests
run: ./vendor/bin/phpunit test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ composer.lock
composer.phar
vendor/*
docker-compose.yml
.phplint-cache
.phpunit.result.cache
61 changes: 61 additions & 0 deletions ci/phpbcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0"?>
<ruleset name="PHP_CodeSniffer">
<description>The coding standard for our project.</description>

<rule ref="PSR1">
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />
</rule>

<rule ref="PSR2"/>

<rule ref="PSR2.Classes.ClassDeclaration"/>
<rule ref="PSR2.Classes.PropertyDeclaration"/>
<rule ref="PSR2.ControlStructures.ControlStructureSpacing"/>
<rule ref="PSR2.ControlStructures.ElseIfDeclaration"/>
<rule ref="PSR2.ControlStructures.SwitchDeclaration"/>
<rule ref="PSR2.Files.EndFileNewline"/>
<rule ref="PSR2.Methods.MethodDeclaration"/>
<rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
<rule ref="PSR2.Namespaces.UseDeclaration"/>

<rule ref="PSR12.Operators.OperatorSpacing"/>

<!--http://edorian.github.io/php-coding-standard-generator/#phpcs-->
<rule ref="Generic.Arrays.DisallowLongArraySyntax" />
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array" value="eval=>NULL,dd=>NULL,dump=>NULL,die=>NULL,var_dump=>NULL,sizeof=>count,delete=>unset,print=>echo,create_function=>NULL"/>
</properties>
</rule>
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
<rule ref="Generic.Formatting.NoSpaceAfterCast"/>
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
<rule ref="Generic.PHP.ForbiddenFunctions"/>
<rule ref="Generic.PHP.LowerCaseConstant"/>
<rule ref="Generic.Strings.UnnecessaryStringConcat"/>
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
<rule ref="Generic.WhiteSpace.ScopeIndent"/>

<rule ref="PEAR.Formatting.MultiLineAssignment"/>
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent"/>
<rule ref="PEAR.WhiteSpace.ScopeClosingBrace"/>

<exclude-pattern>vendor/*</exclude-pattern>
<exclude-pattern>storage/*</exclude-pattern>
<exclude-pattern>bootstrap/*</exclude-pattern>
<exclude-pattern>public/*</exclude-pattern>
<exclude-pattern>*/migrations/*</exclude-pattern>
<exclude-pattern>*/seeds/*</exclude-pattern>
<exclude-pattern>*.blade.php</exclude-pattern>
<exclude-pattern>*.js</exclude-pattern>

<!-- Show progression -->
<arg value="p"/>
<arg value="n"/>
<arg value="s"/>
</ruleset>
6 changes: 6 additions & 0 deletions ci/phplint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
path: ./
jobs: 10
extensions:
- php
exclude:
- vendor
87 changes: 53 additions & 34 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,58 @@
{
"name": "worldia/textmaster-api",
"type": "library",
"description": "Textmaster API v1 client",
"homepage": "https://github.com/worldia/textmaster-api",
"keywords": ["textmaster", "translation", "api"],
"license": "proprietary",
"authors": [
{ "name": "Christian Daguerre", "email": "christian@daguer.re" },
{ "name": "Pierre Ducoudray", "email": "pducoudray@worldia.com" }
],
"require": {
"php": ">=5.6.0",
"ext-curl": "*",
"guzzlehttp/guzzle": "^6.2",
"pagerfanta/pagerfanta": "^1.0",
"phpspec/php-diff": "^1.0"
"name": "worldia/textmaster-api",
"type": "library",
"description": "Textmaster API v1 client",
"homepage": "https://github.com/worldia/textmaster-api",
"keywords": [
"textmaster",
"translation",
"api"
],
"license": "proprietary",
"authors": [
{
"name": "Christian Daguerre",
"email": "christian@daguer.re"
},
"require-dev": {
"phpunit/phpunit": "~5.7",
"friendsofphp/php-cs-fixer": "@stable",
"symfony/http-foundation": "^2.7|^4.0",
"sylius/resource": "1.0.0-beta3",
"doctrine/orm": "^2.3",
"gedmo/doctrine-extensions": "^2.4"
{
"name": "Pierre Ducoudray",
"email": "pducoudray@worldia.com"
},
"suggest": {
"symfony/http-foundation": "To use the callback handler",
"pagerfanta/pagerfanta": "To use the manager"
},
"autoload": {
"psr-4": { "Textmaster\\": "lib/Textmaster/" }
},
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
{
"name": "Remco van Essen",
"email": "remco@productflow.com"
}
],
"require": {
"php": ">=8.0",
"ext-curl": "*",
"guzzlehttp/guzzle": "^7.2",
"pagerfanta/pagerfanta": "^v1.1.0",
"phpspec/php-diff": "^1.0",
"doctrine/inflector": "^2.0",
"doctrine/persistence": "^2"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"symfony/event-dispatcher": "^6.0",
"symfony/http-foundation": "^2.7|^4.0",
"symfony/property-access": "^4.4",
"overtrue/phplint": "^4",
"squizlabs/php_codesniffer": "3.*",
"symplify/easy-ci": "^10.0"
},
"suggest": {
"symfony/http-foundation": "To use the callback handler",
"pagerfanta/pagerfanta": "To use the manager"
},
"autoload": {
"psr-4": {
"Textmaster\\": "lib/Textmaster/"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
}
}
46 changes: 23 additions & 23 deletions lib/Textmaster/Api/AbstractApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getPerPage()
*/
public function setPerPage($perPage)
{
$this->perPage = (null === $perPage ? $perPage : (int) $perPage);
$this->perPage = (null === $perPage ? $perPage : (int)$perPage);

return $this;
}
Expand All @@ -82,7 +82,7 @@ public function getPage()
*/
public function setPage($page)
{
$this->page = (null === $page ? $page : (int) $page);
$this->page = (null === $page ? $page : (int)$page);

return $this;
}
Expand All @@ -100,9 +100,9 @@ public function getClient()
/**
* Send a GET request with query parameters.
*
* @param string $path Request path.
* @param array $parameters GET parameters.
* @param array $requestHeaders Request Headers.
* @param string $path Request path.
* @param array $parameters GET parameters.
* @param array $requestHeaders Request Headers.
*
* @return \GuzzleHttp\Psr7\Stream|mixed|\Psr\Http\Message\StreamInterface
*/
Expand All @@ -126,9 +126,9 @@ protected function get($path, array $parameters = [], $requestHeaders = [])
/**
* Send a HEAD request with query parameters.
*
* @param string $path Request path.
* @param array $parameters HEAD parameters.
* @param array $requestHeaders Request headers.
* @param string $path Request path.
* @param array $parameters HEAD parameters.
* @param array $requestHeaders Request headers.
*
* @return Response
*/
Expand All @@ -144,9 +144,9 @@ protected function head($path, array $parameters = [], $requestHeaders = [])
/**
* Send a POST request with JSON-encoded parameters.
*
* @param string $path Request path.
* @param array $body POST parameters to be JSON encoded.
* @param array $requestHeaders Request headers.
* @param string $path Request path.
* @param array $body POST parameters to be JSON encoded.
* @param array $requestHeaders Request headers.
*
* @return \GuzzleHttp\Psr7\Stream|mixed|\Psr\Http\Message\StreamInterface
*/
Expand All @@ -162,9 +162,9 @@ protected function post($path, array $body = [], $requestHeaders = [])
/**
* Send a POST request with raw data.
*
* @param string $path Request path.
* @param array $body Request body.
* @param array $requestHeaders Request headers.
* @param string $path Request path.
* @param array $body Request body.
* @param array $requestHeaders Request headers.
*
* @return \GuzzleHttp\Psr7\Stream|mixed|\Psr\Http\Message\StreamInterface
*/
Expand All @@ -182,9 +182,9 @@ protected function postRaw($path, array $body, $requestHeaders = [])
/**
* Send a PATCH request with JSON-encoded parameters.
*
* @param string $path Request path.
* @param array $body POST parameters to be JSON encoded.
* @param array $requestHeaders Request headers.
* @param string $path Request path.
* @param array $body POST parameters to be JSON encoded.
* @param array $requestHeaders Request headers.
*
* @return \GuzzleHttp\Psr7\Stream|mixed|\Psr\Http\Message\StreamInterface
*/
Expand All @@ -202,9 +202,9 @@ protected function patch($path, array $body = [], $requestHeaders = [])
/**
* Send a PUT request with JSON-encoded parameters.
*
* @param string $path Request path.
* @param array $body POST parameters to be JSON encoded.
* @param array $requestHeaders Request headers.
* @param string $path Request path.
* @param array $body POST parameters to be JSON encoded.
* @param array $requestHeaders Request headers.
*
* @return \GuzzleHttp\Psr7\Stream|mixed|\Psr\Http\Message\StreamInterface
*/
Expand All @@ -222,9 +222,9 @@ protected function put($path, array $body = [], $requestHeaders = [])
/**
* Send a DELETE request with JSON-encoded parameters.
*
* @param string $path Request path.
* @param array $body POST parameters to be JSON encoded.
* @param array $requestHeaders Request headers.
* @param string $path Request path.
* @param array $body POST parameters to be JSON encoded.
* @param array $requestHeaders Request headers.
*
* @return \GuzzleHttp\Psr7\Stream|mixed|\Psr\Http\Message\StreamInterface
*/
Expand Down
8 changes: 4 additions & 4 deletions lib/Textmaster/Api/Expertise/SubExpertise.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SubExpertise extends AbstractApi
*
* @link https://fr.textmaster.com/documentation#expertises-listing-sub-expertises
*
* @param string $expertiseId
* @param string $expertiseId
* @param null|string $locale
*
* @return array
Expand All @@ -46,8 +46,8 @@ public function all($expertiseId, $locale = null)
*
* @link https://fr.textmaster.com/documentation#expertises-get-a-sub-expertise
*
* @param string $expertiseId
* @param string $subExpertiseId
* @param string $expertiseId
* @param string $subExpertiseId
* @param null|string $locale
*
* @return array
Expand All @@ -60,7 +60,7 @@ public function show($expertiseId, $subExpertiseId, $locale = null)
$params['locale'] = $locale;
}

return $this->get($this->getPath($expertiseId).'/'.rawurlencode($subExpertiseId), $params);
return $this->get($this->getPath($expertiseId) . '/' . rawurlencode($subExpertiseId), $params);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Textmaster/Api/Locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function all()
*/
public function referencePricings($locale)
{
return $this->get('public/reference_pricings/'.rawurlencode($locale));
return $this->get('public/reference_pricings/' . rawurlencode($locale));
}

/**
Expand All @@ -60,6 +60,6 @@ public function referencePricings($locale)
*/
public function countries($locale)
{
return $this->get('public/countries/'.rawurlencode($locale));
return $this->get('public/countries/' . rawurlencode($locale));
}
}
Loading