diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index f8c22e0..8ceb93b 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -12,6 +12,6 @@ jobs:
with:
php-version: 8.3
- run: composer install --no-progress --prefer-dist
- - run: vendor/bin/phpunit
+ - run: composer run check-quality
env:
API_KEY: ${{ secrets.API_KEY }}
diff --git a/.gitignore b/.gitignore
index f8aa5af..009984c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
.phpunit.result.cache
phpunit.xml
vendor
+var
diff --git a/composer.json b/composer.json
index 7cc698a..1c9ad4f 100644
--- a/composer.json
+++ b/composer.json
@@ -1,34 +1,60 @@
{
- "name": "foxentry/php-api-client",
- "description": "Foxentry.com PHP API client",
- "keywords": ["Foxentry", "Foxentry.com"],
- "license": "GPL-3.0-or-later",
- "authors": [
- {
- "name": "Dominik Hošic",
- "email": "hosic@avantro.cz"
- },{
- "name": "Vojtěch Sajdl",
- "email": "sajdl@avantro.cz"
- }
- ],
- "require": {
- "php": ">=7.4",
- "guzzlehttp/guzzle": "^7.8",
- "ext-json": "*"
+ "name": "foxentry/php-api-client",
+ "description": "Foxentry.com PHP API client",
+ "keywords": [
+ "Foxentry",
+ "Foxentry.com"
+ ],
+ "license": "GPL-3.0-or-later",
+ "authors": [
+ {
+ "name": "Dominik Hošic",
+ "email": "hosic@avantro.cz"
},
- "require-dev": {
- "phpunit/phpunit": "^11.3.1"
- },
- "autoload": {
- "psr-4": {
- "Foxentry\\": "src/"
- }
- },
- "autoload-dev": {
- "psr-4": {
- "Tests\\": "tests/",
- "Tests\\Unit\\": "tests/Unit/"
- }
+ {
+ "name": "Vojtěch Sajdl",
+ "email": "sajdl@avantro.cz"
+ }
+ ],
+ "require": {
+ "php": ">=8.1",
+ "guzzlehttp/guzzle": "^7.8",
+ "ext-json": "*"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^11.3.1",
+ "phpstan/phpstan": "^1.12",
+ "squizlabs/php_codesniffer": "^3.10",
+ "slevomat/coding-standard": "^8.15",
+ "phpstan/phpstan-phpunit": "^1.4",
+ "phpstan/extension-installer": "^1.4"
+ },
+ "autoload": {
+ "psr-4": {
+ "Foxentry\\": "src/"
+ }
+ },
+ "autoload-dev": {
+ "psr-4": {
+ "Tests\\": "tests/",
+ "Tests\\Unit\\": "tests/Unit/"
+ }
+ },
+ "config": {
+ "allow-plugins": {
+ "dealerdirect/phpcodesniffer-composer-installer": true,
+ "phpstan/extension-installer": true
}
+ },
+ "scripts": {
+ "lint": "phpcs -s",
+ "lint-fix": "phpcbf",
+ "phpstan": "phpstan analyse -c phpstan.neon",
+ "test": "phpunit",
+ "check-quality": [
+ "@lint",
+ "@phpstan",
+ "@test"
+ ]
+ }
}
diff --git a/composer.lock b/composer.lock
index ca60f57..4791c39 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "29eac92058cf77d0b55646c736502637",
+ "content-hash": "48fd746ba0dd40952e1ee6c95ea3cb48",
"packages": [
{
"name": "guzzlehttp/guzzle",
@@ -134,16 +134,16 @@
},
{
"name": "guzzlehttp/promises",
- "version": "2.0.3",
+ "version": "2.0.4",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
- "reference": "6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8"
+ "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/promises/zipball/6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8",
- "reference": "6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8",
+ "url": "https://api.github.com/repos/guzzle/promises/zipball/f9c436286ab2892c7db7be8c8da4ef61ccf7b455",
+ "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455",
"shasum": ""
},
"require": {
@@ -197,7 +197,7 @@
],
"support": {
"issues": "https://github.com/guzzle/promises/issues",
- "source": "https://github.com/guzzle/promises/tree/2.0.3"
+ "source": "https://github.com/guzzle/promises/tree/2.0.4"
},
"funding": [
{
@@ -213,7 +213,7 @@
"type": "tidelift"
}
],
- "time": "2024-07-18T10:29:17+00:00"
+ "time": "2024-10-17T10:06:22+00:00"
},
{
"name": "guzzlehttp/psr7",
@@ -604,6 +604,84 @@
}
],
"packages-dev": [
+ {
+ "name": "dealerdirect/phpcodesniffer-composer-installer",
+ "version": "v1.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/PHPCSStandards/composer-installer.git",
+ "reference": "4be43904336affa5c2f70744a348312336afd0da"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/4be43904336affa5c2f70744a348312336afd0da",
+ "reference": "4be43904336affa5c2f70744a348312336afd0da",
+ "shasum": ""
+ },
+ "require": {
+ "composer-plugin-api": "^1.0 || ^2.0",
+ "php": ">=5.4",
+ "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0"
+ },
+ "require-dev": {
+ "composer/composer": "*",
+ "ext-json": "*",
+ "ext-zip": "*",
+ "php-parallel-lint/php-parallel-lint": "^1.3.1",
+ "phpcompatibility/php-compatibility": "^9.0",
+ "yoast/phpunit-polyfills": "^1.0"
+ },
+ "type": "composer-plugin",
+ "extra": {
+ "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin"
+ },
+ "autoload": {
+ "psr-4": {
+ "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Franck Nijhof",
+ "email": "franck.nijhof@dealerdirect.com",
+ "homepage": "http://www.frenck.nl",
+ "role": "Developer / IT Manager"
+ },
+ {
+ "name": "Contributors",
+ "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors"
+ }
+ ],
+ "description": "PHP_CodeSniffer Standards Composer Installer Plugin",
+ "homepage": "http://www.dealerdirect.com",
+ "keywords": [
+ "PHPCodeSniffer",
+ "PHP_CodeSniffer",
+ "code quality",
+ "codesniffer",
+ "composer",
+ "installer",
+ "phpcbf",
+ "phpcs",
+ "plugin",
+ "qa",
+ "quality",
+ "standard",
+ "standards",
+ "style guide",
+ "stylecheck",
+ "tests"
+ ],
+ "support": {
+ "issues": "https://github.com/PHPCSStandards/composer-installer/issues",
+ "source": "https://github.com/PHPCSStandards/composer-installer"
+ },
+ "time": "2023-01-05T11:28:13+00:00"
+ },
{
"name": "myclabs/deep-copy",
"version": "1.12.0",
@@ -666,16 +744,16 @@
},
{
"name": "nikic/php-parser",
- "version": "v5.1.0",
+ "version": "v5.3.1",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
- "reference": "683130c2ff8c2739f4822ff7ac5c873ec529abd1"
+ "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/683130c2ff8c2739f4822ff7ac5c873ec529abd1",
- "reference": "683130c2ff8c2739f4822ff7ac5c873ec529abd1",
+ "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/8eea230464783aa9671db8eea6f8c6ac5285794b",
+ "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b",
"shasum": ""
},
"require": {
@@ -718,9 +796,9 @@
],
"support": {
"issues": "https://github.com/nikic/PHP-Parser/issues",
- "source": "https://github.com/nikic/PHP-Parser/tree/v5.1.0"
+ "source": "https://github.com/nikic/PHP-Parser/tree/v5.3.1"
},
- "time": "2024-07-01T20:03:41+00:00"
+ "time": "2024-10-08T18:51:32+00:00"
},
{
"name": "phar-io/manifest",
@@ -840,37 +918,242 @@
},
"time": "2022-02-21T01:04:05+00:00"
},
+ {
+ "name": "phpstan/extension-installer",
+ "version": "1.4.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpstan/extension-installer.git",
+ "reference": "85e90b3942d06b2326fba0403ec24fe912372936"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/85e90b3942d06b2326fba0403ec24fe912372936",
+ "reference": "85e90b3942d06b2326fba0403ec24fe912372936",
+ "shasum": ""
+ },
+ "require": {
+ "composer-plugin-api": "^2.0",
+ "php": "^7.2 || ^8.0",
+ "phpstan/phpstan": "^1.9.0 || ^2.0"
+ },
+ "require-dev": {
+ "composer/composer": "^2.0",
+ "php-parallel-lint/php-parallel-lint": "^1.2.0",
+ "phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0"
+ },
+ "type": "composer-plugin",
+ "extra": {
+ "class": "PHPStan\\ExtensionInstaller\\Plugin"
+ },
+ "autoload": {
+ "psr-4": {
+ "PHPStan\\ExtensionInstaller\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "Composer plugin for automatic installation of PHPStan extensions",
+ "keywords": [
+ "dev",
+ "static analysis"
+ ],
+ "support": {
+ "issues": "https://github.com/phpstan/extension-installer/issues",
+ "source": "https://github.com/phpstan/extension-installer/tree/1.4.3"
+ },
+ "time": "2024-09-04T20:21:43+00:00"
+ },
+ {
+ "name": "phpstan/phpdoc-parser",
+ "version": "1.33.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpstan/phpdoc-parser.git",
+ "reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/82a311fd3690fb2bf7b64d5c98f912b3dd746140",
+ "reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.2 || ^8.0"
+ },
+ "require-dev": {
+ "doctrine/annotations": "^2.0",
+ "nikic/php-parser": "^4.15",
+ "php-parallel-lint/php-parallel-lint": "^1.2",
+ "phpstan/extension-installer": "^1.0",
+ "phpstan/phpstan": "^1.5",
+ "phpstan/phpstan-phpunit": "^1.1",
+ "phpstan/phpstan-strict-rules": "^1.0",
+ "phpunit/phpunit": "^9.5",
+ "symfony/process": "^5.2"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "PHPStan\\PhpDocParser\\": [
+ "src/"
+ ]
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "PHPDoc parser with support for nullable, intersection and generic types",
+ "support": {
+ "issues": "https://github.com/phpstan/phpdoc-parser/issues",
+ "source": "https://github.com/phpstan/phpdoc-parser/tree/1.33.0"
+ },
+ "time": "2024-10-13T11:25:22+00:00"
+ },
+ {
+ "name": "phpstan/phpstan",
+ "version": "1.12.7",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpstan/phpstan.git",
+ "reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpstan/phpstan/zipball/dc2b9976bd8b0f84ec9b0e50cc35378551de7af0",
+ "reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.2|^8.0"
+ },
+ "conflict": {
+ "phpstan/phpstan-shim": "*"
+ },
+ "bin": [
+ "phpstan",
+ "phpstan.phar"
+ ],
+ "type": "library",
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "PHPStan - PHP Static Analysis Tool",
+ "keywords": [
+ "dev",
+ "static analysis"
+ ],
+ "support": {
+ "docs": "https://phpstan.org/user-guide/getting-started",
+ "forum": "https://github.com/phpstan/phpstan/discussions",
+ "issues": "https://github.com/phpstan/phpstan/issues",
+ "security": "https://github.com/phpstan/phpstan/security/policy",
+ "source": "https://github.com/phpstan/phpstan-src"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/ondrejmirtes",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/phpstan",
+ "type": "github"
+ }
+ ],
+ "time": "2024-10-18T11:12:07+00:00"
+ },
+ {
+ "name": "phpstan/phpstan-phpunit",
+ "version": "1.4.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpstan/phpstan-phpunit.git",
+ "reference": "f3ea021866f4263f07ca3636bf22c64be9610c11"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/f3ea021866f4263f07ca3636bf22c64be9610c11",
+ "reference": "f3ea021866f4263f07ca3636bf22c64be9610c11",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.2 || ^8.0",
+ "phpstan/phpstan": "^1.11"
+ },
+ "conflict": {
+ "phpunit/phpunit": "<7.0"
+ },
+ "require-dev": {
+ "nikic/php-parser": "^4.13.0",
+ "php-parallel-lint/php-parallel-lint": "^1.2",
+ "phpstan/phpstan-strict-rules": "^1.5.1",
+ "phpunit/phpunit": "^9.5"
+ },
+ "type": "phpstan-extension",
+ "extra": {
+ "phpstan": {
+ "includes": [
+ "extension.neon",
+ "rules.neon"
+ ]
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "PHPStan\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "PHPUnit extensions and rules for PHPStan",
+ "support": {
+ "issues": "https://github.com/phpstan/phpstan-phpunit/issues",
+ "source": "https://github.com/phpstan/phpstan-phpunit/tree/1.4.0"
+ },
+ "time": "2024-04-20T06:39:00+00:00"
+ },
{
"name": "phpunit/php-code-coverage",
- "version": "11.0.6",
+ "version": "11.0.7",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
- "reference": "ebdffc9e09585dafa71b9bffcdb0a229d4704c45"
+ "reference": "f7f08030e8811582cc459871d28d6f5a1a4d35ca"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ebdffc9e09585dafa71b9bffcdb0a229d4704c45",
- "reference": "ebdffc9e09585dafa71b9bffcdb0a229d4704c45",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f7f08030e8811582cc459871d28d6f5a1a4d35ca",
+ "reference": "f7f08030e8811582cc459871d28d6f5a1a4d35ca",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-libxml": "*",
"ext-xmlwriter": "*",
- "nikic/php-parser": "^5.1.0",
+ "nikic/php-parser": "^5.3.1",
"php": ">=8.2",
- "phpunit/php-file-iterator": "^5.0.1",
+ "phpunit/php-file-iterator": "^5.1.0",
"phpunit/php-text-template": "^4.0.1",
"sebastian/code-unit-reverse-lookup": "^4.0.1",
"sebastian/complexity": "^4.0.1",
"sebastian/environment": "^7.2.0",
"sebastian/lines-of-code": "^3.0.1",
- "sebastian/version": "^5.0.1",
+ "sebastian/version": "^5.0.2",
"theseer/tokenizer": "^1.2.3"
},
"require-dev": {
- "phpunit/phpunit": "^11.0"
+ "phpunit/phpunit": "^11.4.1"
},
"suggest": {
"ext-pcov": "PHP extension that provides line coverage",
@@ -908,7 +1191,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
"security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy",
- "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/11.0.6"
+ "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/11.0.7"
},
"funding": [
{
@@ -916,7 +1199,7 @@
"type": "github"
}
],
- "time": "2024-08-22T04:37:56+00:00"
+ "time": "2024-10-09T06:21:38+00:00"
},
{
"name": "phpunit/php-file-iterator",
@@ -1165,16 +1448,16 @@
},
{
"name": "phpunit/phpunit",
- "version": "11.3.1",
+ "version": "11.4.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "fe179875ef0c14e90b75617002767eae0a742641"
+ "reference": "1863643c3f04ad03dcb9c6996c294784cdda4805"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fe179875ef0c14e90b75617002767eae0a742641",
- "reference": "fe179875ef0c14e90b75617002767eae0a742641",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1863643c3f04ad03dcb9c6996c294784cdda4805",
+ "reference": "1863643c3f04ad03dcb9c6996c294784cdda4805",
"shasum": ""
},
"require": {
@@ -1188,21 +1471,21 @@
"phar-io/manifest": "^2.0.4",
"phar-io/version": "^3.2.1",
"php": ">=8.2",
- "phpunit/php-code-coverage": "^11.0.5",
- "phpunit/php-file-iterator": "^5.0.1",
+ "phpunit/php-code-coverage": "^11.0.7",
+ "phpunit/php-file-iterator": "^5.1.0",
"phpunit/php-invoker": "^5.0.1",
"phpunit/php-text-template": "^4.0.1",
"phpunit/php-timer": "^7.0.1",
"sebastian/cli-parser": "^3.0.2",
"sebastian/code-unit": "^3.0.1",
- "sebastian/comparator": "^6.0.2",
+ "sebastian/comparator": "^6.1.1",
"sebastian/diff": "^6.0.2",
"sebastian/environment": "^7.2.0",
"sebastian/exporter": "^6.1.3",
"sebastian/global-state": "^7.0.2",
"sebastian/object-enumerator": "^6.0.1",
- "sebastian/type": "^5.0.1",
- "sebastian/version": "^5.0.1"
+ "sebastian/type": "^5.1.0",
+ "sebastian/version": "^5.0.2"
},
"suggest": {
"ext-soap": "To be able to generate mocks based on WSDL files"
@@ -1213,7 +1496,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "11.3-dev"
+ "dev-main": "11.4-dev"
}
},
"autoload": {
@@ -1245,7 +1528,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
- "source": "https://github.com/sebastianbergmann/phpunit/tree/11.3.1"
+ "source": "https://github.com/sebastianbergmann/phpunit/tree/11.4.2"
},
"funding": [
{
@@ -1261,7 +1544,7 @@
"type": "tidelift"
}
],
- "time": "2024-08-13T06:14:23+00:00"
+ "time": "2024-10-19T13:05:19+00:00"
},
{
"name": "sebastian/cli-parser",
@@ -1435,16 +1718,16 @@
},
{
"name": "sebastian/comparator",
- "version": "6.0.2",
+ "version": "6.1.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/comparator.git",
- "reference": "450d8f237bd611c45b5acf0733ce43e6bb280f81"
+ "reference": "5ef523a49ae7a302b87b2102b72b1eda8918d686"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/450d8f237bd611c45b5acf0733ce43e6bb280f81",
- "reference": "450d8f237bd611c45b5acf0733ce43e6bb280f81",
+ "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5ef523a49ae7a302b87b2102b72b1eda8918d686",
+ "reference": "5ef523a49ae7a302b87b2102b72b1eda8918d686",
"shasum": ""
},
"require": {
@@ -1455,12 +1738,12 @@
"sebastian/exporter": "^6.0"
},
"require-dev": {
- "phpunit/phpunit": "^11.0"
+ "phpunit/phpunit": "^11.3"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "6.0-dev"
+ "dev-main": "6.1-dev"
}
},
"autoload": {
@@ -1500,7 +1783,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/comparator/issues",
"security": "https://github.com/sebastianbergmann/comparator/security/policy",
- "source": "https://github.com/sebastianbergmann/comparator/tree/6.0.2"
+ "source": "https://github.com/sebastianbergmann/comparator/tree/6.1.1"
},
"funding": [
{
@@ -1508,7 +1791,7 @@
"type": "github"
}
],
- "time": "2024-08-12T06:07:25+00:00"
+ "time": "2024-10-18T15:00:48+00:00"
},
{
"name": "sebastian/complexity",
@@ -2077,28 +2360,28 @@
},
{
"name": "sebastian/type",
- "version": "5.0.1",
+ "version": "5.1.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/type.git",
- "reference": "fb6a6566f9589e86661291d13eba708cce5eb4aa"
+ "reference": "461b9c5da241511a2a0e8f240814fb23ce5c0aac"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb6a6566f9589e86661291d13eba708cce5eb4aa",
- "reference": "fb6a6566f9589e86661291d13eba708cce5eb4aa",
+ "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/461b9c5da241511a2a0e8f240814fb23ce5c0aac",
+ "reference": "461b9c5da241511a2a0e8f240814fb23ce5c0aac",
"shasum": ""
},
"require": {
"php": ">=8.2"
},
"require-dev": {
- "phpunit/phpunit": "^11.0"
+ "phpunit/phpunit": "^11.3"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "5.0-dev"
+ "dev-main": "5.1-dev"
}
},
"autoload": {
@@ -2122,7 +2405,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/type/issues",
"security": "https://github.com/sebastianbergmann/type/security/policy",
- "source": "https://github.com/sebastianbergmann/type/tree/5.0.1"
+ "source": "https://github.com/sebastianbergmann/type/tree/5.1.0"
},
"funding": [
{
@@ -2130,20 +2413,20 @@
"type": "github"
}
],
- "time": "2024-07-03T05:11:49+00:00"
+ "time": "2024-09-17T13:12:04+00:00"
},
{
"name": "sebastian/version",
- "version": "5.0.1",
+ "version": "5.0.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/version.git",
- "reference": "45c9debb7d039ce9b97de2f749c2cf5832a06ac4"
+ "reference": "c687e3387b99f5b03b6caa64c74b63e2936ff874"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/45c9debb7d039ce9b97de2f749c2cf5832a06ac4",
- "reference": "45c9debb7d039ce9b97de2f749c2cf5832a06ac4",
+ "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c687e3387b99f5b03b6caa64c74b63e2936ff874",
+ "reference": "c687e3387b99f5b03b6caa64c74b63e2936ff874",
"shasum": ""
},
"require": {
@@ -2176,7 +2459,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/version/issues",
"security": "https://github.com/sebastianbergmann/version/security/policy",
- "source": "https://github.com/sebastianbergmann/version/tree/5.0.1"
+ "source": "https://github.com/sebastianbergmann/version/tree/5.0.2"
},
"funding": [
{
@@ -2184,7 +2467,152 @@
"type": "github"
}
],
- "time": "2024-07-03T05:13:08+00:00"
+ "time": "2024-10-09T05:16:32+00:00"
+ },
+ {
+ "name": "slevomat/coding-standard",
+ "version": "8.15.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/slevomat/coding-standard.git",
+ "reference": "7d1d957421618a3803b593ec31ace470177d7817"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/7d1d957421618a3803b593ec31ace470177d7817",
+ "reference": "7d1d957421618a3803b593ec31ace470177d7817",
+ "shasum": ""
+ },
+ "require": {
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0",
+ "php": "^7.2 || ^8.0",
+ "phpstan/phpdoc-parser": "^1.23.1",
+ "squizlabs/php_codesniffer": "^3.9.0"
+ },
+ "require-dev": {
+ "phing/phing": "2.17.4",
+ "php-parallel-lint/php-parallel-lint": "1.3.2",
+ "phpstan/phpstan": "1.10.60",
+ "phpstan/phpstan-deprecation-rules": "1.1.4",
+ "phpstan/phpstan-phpunit": "1.3.16",
+ "phpstan/phpstan-strict-rules": "1.5.2",
+ "phpunit/phpunit": "8.5.21|9.6.8|10.5.11"
+ },
+ "type": "phpcodesniffer-standard",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "8.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "SlevomatCodingStandard\\": "SlevomatCodingStandard/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.",
+ "keywords": [
+ "dev",
+ "phpcs"
+ ],
+ "support": {
+ "issues": "https://github.com/slevomat/coding-standard/issues",
+ "source": "https://github.com/slevomat/coding-standard/tree/8.15.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/kukulich",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/slevomat/coding-standard",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-03-09T15:20:58+00:00"
+ },
+ {
+ "name": "squizlabs/php_codesniffer",
+ "version": "3.10.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git",
+ "reference": "62d32998e820bddc40f99f8251958aed187a5c9c"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/62d32998e820bddc40f99f8251958aed187a5c9c",
+ "reference": "62d32998e820bddc40f99f8251958aed187a5c9c",
+ "shasum": ""
+ },
+ "require": {
+ "ext-simplexml": "*",
+ "ext-tokenizer": "*",
+ "ext-xmlwriter": "*",
+ "php": ">=5.4.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4"
+ },
+ "bin": [
+ "bin/phpcbf",
+ "bin/phpcs"
+ ],
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.x-dev"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Greg Sherwood",
+ "role": "Former lead"
+ },
+ {
+ "name": "Juliette Reinders Folmer",
+ "role": "Current lead"
+ },
+ {
+ "name": "Contributors",
+ "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors"
+ }
+ ],
+ "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
+ "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer",
+ "keywords": [
+ "phpcs",
+ "standards",
+ "static analysis"
+ ],
+ "support": {
+ "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues",
+ "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy",
+ "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer",
+ "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/PHPCSStandards",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/jrfnl",
+ "type": "github"
+ },
+ {
+ "url": "https://opencollective.com/php_codesniffer",
+ "type": "open_collective"
+ }
+ ],
+ "time": "2024-09-18T10:38:58+00:00"
},
{
"name": "theseer/tokenizer",
@@ -2243,7 +2671,7 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
- "php": ">=7.4",
+ "php": ">=8.1",
"ext-json": "*"
},
"platform-dev": [],
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 0000000..7f17f87
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,59 @@
+
+
+ Slim coding standard
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+ src
+ tests
+
+
diff --git a/phpstan.neon b/phpstan.neon
new file mode 100644
index 0000000..47a2029
--- /dev/null
+++ b/phpstan.neon
@@ -0,0 +1,13 @@
+parameters:
+ level: 8
+ phpVersion: 80100
+
+ tmpDir: %currentWorkingDirectory%/var/tmp/phpstan
+
+ fileExtensions:
+ - php
+ - phpt
+
+ paths:
+ - src
+ - tests
diff --git a/src/ApiClient.php b/src/ApiClient.php
index ab13b52..cb6e55b 100644
--- a/src/ApiClient.php
+++ b/src/ApiClient.php
@@ -1,5 +1,7 @@
setAuth($apiKey);
}
@@ -35,7 +38,8 @@ public function __construct( ?string $apiKey = null ) {
*
* @param string $apiKey The API key to set
*/
- public function setAuth( string $apiKey ): void {
+ public function setAuth(string $apiKey): void
+ {
$this->apiKey = $apiKey;
}
@@ -44,34 +48,39 @@ public function setAuth( string $apiKey ): void {
*
* @param string $version The API version to set
*/
- public function setApiVersion( string $version ): void {
+ public function setApiVersion(string $version): void
+ {
$this->apiVersion = $version;
}
- function company() {
+ public function company(): Company
+ {
$request = new Request($this->apiVersion, $this->apiKey);
- return new Company( $request );
+ return new Company($request);
}
- function email() {
+ public function email(): Email
+ {
$request = new Request($this->apiVersion, $this->apiKey);
- return new Email( $request );
+ return new Email($request);
}
- function location() {
+ public function location(): Location
+ {
$request = new Request($this->apiVersion, $this->apiKey);
- return new Location( $request );
+ return new Location($request);
}
- function name() {
+ public function name(): Name
+ {
$request = new Request($this->apiVersion, $this->apiKey);
- return new Name( $request );
+ return new Name($request);
}
- function phone() {
+ public function phone(): Phone
+ {
$request = new Request($this->apiVersion, $this->apiKey);
- return new Phone( $request );
+ return new Phone($request);
}
-
}
diff --git a/src/Exception/BadRequestException.php b/src/Exception/BadRequestException.php
index 0965bdd..20e2a01 100644
--- a/src/Exception/BadRequestException.php
+++ b/src/Exception/BadRequestException.php
@@ -1,5 +1,7 @@
hasResponse()) {
- $statusCode = $e->getResponse()->getStatusCode();
-
+ $statusCode = $e->getResponse()?->getStatusCode() ?? -1;
// Switch based on the status code of the response
switch ($statusCode) {
case 400:
- return new BadRequestException("Request was invalid or cannot be processed.");
+ $foxentryException = new BadRequestException('Request was invalid or cannot be processed.');
+ break;
case 401:
- return new UnauthorizedException("Unauthorized. Did you set your API key?");
+ $foxentryException = new UnauthorizedException('Unauthorized. Did you set your API key?');
+ break;
case 402:
- return new PaymentRequiredException("Payment is required to access this resource.");
+ $foxentryException = new PaymentRequiredException('Payment is required to access this resource.');
+ break;
case 403:
- return new ForbiddenException("Forbidden.");
+ $foxentryException = new ForbiddenException('Forbidden.');
+ break;
case 404:
- return new NotFoundException("Resource or endpoint requested is not found on the server.");
+ $foxentryException = new NotFoundException('Resource or endpoint requested is not found on the server.');
+ break;
case 429:
- return new TooManyRequestsException("Too many requests have been made in the given time frame or the daily limit has been reached.");
+ $foxentryException = new TooManyRequestsException(
+ 'Too many requests have been made in the given time frame or the daily limit has been reached.'
+ );
+ break;
case 500:
- return new ServerErrorException("Internal server error.");
+ $foxentryException = new ServerErrorException('Internal server error.');
+ break;
case 503:
- return new ServiceUnavailableException("The server is temporarily unable to handle the request");
+ $foxentryException = new ServiceUnavailableException('The server is temporarily unable to handle the request');
+ break;
default:
// Handle the rest with generic FoxentryException class
- return new self("Request exception: " . $e->getResponse()->getBody()->getContents(), $statusCode);
+ $foxentryException = new self('Request exception: ' . $e->getMessage(), $statusCode);
+ break;
}
- } else {
- // Return a generic exception with the original exception message
- return new self("Exception: " . $e->getMessage());
+
+ return $foxentryException->setResponse($e->getResponse());
}
+
+ // Return a generic exception with the original exception message
+ return new self('Exception: ' . $e->getMessage());
+ }
+
+ public function setResponse(?ResponseInterface $response): self
+ {
+ $this->response = $response;
+ return $this;
+ }
+
+ public function getResponse(): ?ResponseInterface
+ {
+ return $this->response;
}
-}
\ No newline at end of file
+}
diff --git a/src/Exception/NotFoundException.php b/src/Exception/NotFoundException.php
index f27ee67..8bb6db5 100644
--- a/src/Exception/NotFoundException.php
+++ b/src/Exception/NotFoundException.php
@@ -1,5 +1,7 @@
*/
private array $headers = [
- "Foxentry-Include-Request-Details" => false,
- "Content-Type" => "application/json",
- "Accept" => "application/json",
- "User-Agent" => "FoxentrySdk (PHP/2.3.0; ApiReference/2.0)"
+ 'Foxentry-Include-Request-Details' => false,
+ 'Content-Type' => 'application/json',
+ 'Accept' => 'application/json',
+ 'User-Agent' => 'FoxentrySdk (PHP/2.3.0; ApiReference/2.0)',
];
/**
* The request body data to send to the API.
*
- * @var object
*/
private object $body;
/**
* A custom ID for the request (optional).
*
- * @var string|null
*/
private ?string $customId = null;
/**
* The query parameters for the API request.
*
- * @var array
+ * @var array
*/
private array $query;
/**
* Additional options for the API request (optional).
*
- * @var array|null
+ * @var array|null
*/
private ?array $options = null;
/**
* The API endpoint to send the request to.
*
- * @var string
*/
private string $endpoint;
/**
* The HTTP client for making requests.
*
- * @var HttpClient
*/
private HttpClient $httpClient;
/**
* The API key used for authentication.
*
- * @var string
*/
private string $apiKey;
/**
* Information about the client making the request (optional).
*
- * @var object|null
+ * @var array
*/
- private ?object $client = null;
+ private ?array $client = null;
- public function __construct(string $apiVersion, ?string $apiKey) {
- $this->setHeader("Api-Version", $apiVersion);
+ public function __construct(string $apiVersion, ?string $apiKey)
+ {
+ $this->setHeader('Api-Version', $apiVersion);
- if ($apiKey){
+ if ($apiKey) {
$this->setAuth($apiKey);
}
@@ -123,7 +119,7 @@ public function __construct(string $apiVersion, ?string $apiKey) {
public function setAuth(string $apiKey): void
{
$this->apiKey = $apiKey;
- $this->setHeader("Authorization", "Bearer $this->apiKey");
+ $this->setHeader('Authorization', sprintf('Bearer %s', $this->apiKey));
}
/**
@@ -132,7 +128,7 @@ public function setAuth(string $apiKey): void
* @param string $key The header key
* @param mixed $value The header value
*/
- public function setHeader(string $key, $value): void
+ public function setHeader(string $key, mixed $value): void
{
$this->headers[$key] = $value;
}
@@ -150,7 +146,7 @@ public function setCustomId(string $id): void
/**
* Set query parameters for the request.
*
- * @param array $query The query parameters to set
+ * @param array $query The query parameters to set
*/
public function setQuery(array $query): void
{
@@ -160,7 +156,7 @@ public function setQuery(array $query): void
/**
* Set options for the request.
*
- * @param array $options The options to set
+ * @param array $options The options to set
*/
public function setOptions(array $options): void
{
@@ -184,13 +180,15 @@ public function setEndpoint(string $endpoint): void
*/
public function setClientIP(string $ip): void
{
- if(!filter_var($ip, FILTER_VALIDATE_IP))
- throw new \InvalidArgumentException("The specified IP address is not valid.");
+ if (!filter_var($ip, FILTER_VALIDATE_IP)) {
+ throw new \InvalidArgumentException('The specified IP address is not valid.');
+ }
- if(empty($this->client))
- $this->client = new \stdClass();
+ if ($this->client === null) {
+ $this->client = [];
+ }
- $this->client->ip = $ip;
+ $this->client['ip'] = $ip;
}
/**
@@ -200,13 +198,15 @@ public function setClientIP(string $ip): void
*/
public function setClientCountry(string $country): void
{
- if(strlen($country) != 2)
- throw new \InvalidArgumentException("The provided country code does not conform to the ISO-3166-1 alpha-2 format.");
+ if (strlen($country) != 2) {
+ throw new \InvalidArgumentException('The provided country code does not conform to the ISO-3166-1 alpha-2 format.');
+ }
- if(empty($this->client))
- $this->client = new \stdClass();
+ if ($this->client === null) {
+ $this->client = [];
+ }
- $this->client->country = $country;
+ $this->client['country'] = $country;
}
/**
@@ -218,14 +218,15 @@ public function setClientCountry(string $country): void
public function setClientLocation(float $lat, float $lon): void
{
$location = [
- "lat" => $lat,
- "lon" => $lon,
+ 'lat' => $lat,
+ 'lon' => $lon,
];
- if(empty($this->client))
- $this->client = new \stdClass();
+ if ($this->client === null) {
+ $this->client = [];
+ }
- $this->client->location = (object)$location;
+ $this->client['location'] = $location;
}
/**
@@ -250,8 +251,8 @@ public function send(): Response
$this->validate();
$response = $this->httpClient->request($this->method, $this->endpoint, [
- "headers" => $this->headers,
- "body" => json_encode($this->body)
+ 'headers' => $this->headers,
+ 'body' => json_encode($this->body),
]);
$responseHeaders = $response->getHeaders();
@@ -269,12 +270,12 @@ public function send(): Response
private function buildBody(): void
{
$body = [
- "request" => [
- "customId" => $this->customId,
- "query" => $this->query,
- "options" => $this->options,
- "client" => $this->client
- ]
+ 'request' => [
+ 'customId' => $this->customId,
+ 'query' => $this->query,
+ 'options' => $this->options,
+ 'client' => $this->client,
+ ],
];
$this->body = (object)$body;
diff --git a/src/Resource/BaseResource.php b/src/Resource/BaseResource.php
index 25a88f5..59c33db 100644
--- a/src/Resource/BaseResource.php
+++ b/src/Resource/BaseResource.php
@@ -1,9 +1,20 @@
request->setHeader( "Foxentry-Include-Request-Details", $value );
+ public function includeRequestDetails(bool $value = true): static
+ {
+ $this->request->setHeader('Foxentry-Include-Request-Details', $value);
return $this;
}
@@ -39,9 +51,9 @@ public function includeRequestDetails( bool $value = true ): self {
*
* @param string $id The custom ID to set
*
- * @return BaseResource Returns $this for method chaining
+ * @return $this Returns $this for method chaining
*/
- public function setCustomId(string $id): BaseResource
+ public function setCustomId(string $id): self
{
$this->request->setCustomId($id);
return $this;
@@ -50,11 +62,11 @@ public function setCustomId(string $id): BaseResource
/**
* Set options for the resource request.
*
- * @param array $options The options to set
+ * @param array $options The options to set
*
- * @return BaseResource Returns $this for method chaining
+ * @return $this Returns $this for method chaining
*/
- public function setOptions(array $options): BaseResource
+ public function setOptions(array $options): self
{
$this->request->setOptions($options);
return $this;
@@ -65,9 +77,9 @@ public function setOptions(array $options): BaseResource
*
* @param string $ip The client IP address
*
- * @return BaseResource Returns $this for method chaining
+ * @return $this Returns $this for method chaining
*/
- public function setClientIP(string $ip): BaseResource
+ public function setClientIP(string $ip): self
{
$this->request->setClientIP($ip);
return $this;
@@ -78,10 +90,10 @@ public function setClientIP(string $ip): BaseResource
*
* @param string $country The client country code in format ISO-3166-1 alpha-2.
*
- * @return BaseResource Returns $this for method chaining
+ * @return $this Returns $this for method chaining
* @see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 ISO-3166-1 alpha-2 country code format
*/
- public function setClientCountry(string $country): BaseResource
+ public function setClientCountry(string $country): self
{
$this->request->setClientCountry($country);
return $this;
@@ -93,9 +105,9 @@ public function setClientCountry(string $country): BaseResource
* @param float $lon The client's longitude
* @param float $lat The client's latitude
*
- * @return BaseResource Returns $this for method chaining
+ * @return $this Returns $this for method chaining
*/
- public function setClientLocation(float $lat, float $lon): BaseResource
+ public function setClientLocation(float $lat, float $lon): self
{
$this->request->setClientLocation($lat, $lon);
return $this;
@@ -104,10 +116,18 @@ public function setClientLocation(float $lat, float $lon): BaseResource
/**
* Send a request to the API with the given query parameters.
*
- * @param array $query The query parameters for the request
+ * @param array $query The query parameters for the request
*
* @return Response The response from the API
- * @throws \Exception
+ * @throws TooManyRequestsException
+ * @throws BadRequestException
+ * @throws ForbiddenException
+ * @throws NotFoundException
+ * @throws PaymentRequiredException
+ * @throws ServerErrorException
+ * @throws UnauthorizedException
+ * @throws FoxentryException
+ * @throws GuzzleException
*/
protected function send(array $query): Response
{
@@ -129,6 +149,6 @@ private function getCallerEndpoint(): string
$class = strtolower($class);
$method = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 4)[3]['function'];
- return "$class/$method";
+ return $class . '/' . $method;
}
}
diff --git a/src/Resource/Company.php b/src/Resource/Company.php
index 14ae403..a93b7ea 100644
--- a/src/Resource/Company.php
+++ b/src/Resource/Company.php
@@ -1,8 +1,19 @@
$query Query parameters for the validation request
*
* @return Response The response from the validation request
+ *
+ * @return Response The response from the API
+ * @throws TooManyRequestsException
+ * @throws BadRequestException
+ * @throws ForbiddenException
+ * @throws NotFoundException
+ * @throws PaymentRequiredException
+ * @throws ServerErrorException
+ * @throws UnauthorizedException
+ * @throws FoxentryException
+ * @throws GuzzleException
*/
public function validate(array $query): Response
{
@@ -26,9 +48,20 @@ public function validate(array $query): Response
/**
* Search for a company.
*
- * @param array $query Query parameters for the search request
+ * @param array $query Query parameters for the search request
+ *
+ * @return Response The response from the API
*
* @return Response The response from the API
+ * @throws TooManyRequestsException
+ * @throws BadRequestException
+ * @throws ForbiddenException
+ * @throws NotFoundException
+ * @throws PaymentRequiredException
+ * @throws ServerErrorException
+ * @throws UnauthorizedException
+ * @throws FoxentryException
+ * @throws GuzzleException
*/
public function search(array $query): Response
{
@@ -38,9 +71,20 @@ public function search(array $query): Response
/**
* Get company details.
*
- * @param array $query Query parameters for the get request
+ * @param array $query Query parameters for the get request
*
* @return Response The response from the API
+ *
+ * @return Response The response from the API
+ * @throws TooManyRequestsException
+ * @throws BadRequestException
+ * @throws ForbiddenException
+ * @throws NotFoundException
+ * @throws PaymentRequiredException
+ * @throws ServerErrorException
+ * @throws UnauthorizedException
+ * @throws FoxentryException
+ * @throws GuzzleException
*/
public function get(array $query): Response
{
@@ -50,12 +94,23 @@ public function get(array $query): Response
/**
* Send a request to the API with the given query parameters.
*
- * @param array $query Query parameters for the request
+ * @param array $query Query parameters for the request
+ *
+ * @return Response The response from the API
*
* @return Response The response from the API
+ * @throws TooManyRequestsException
+ * @throws BadRequestException
+ * @throws ForbiddenException
+ * @throws NotFoundException
+ * @throws PaymentRequiredException
+ * @throws ServerErrorException
+ * @throws UnauthorizedException
+ * @throws FoxentryException
+ * @throws GuzzleException
*/
private function sendRequest(array $query): Response
{
- return parent::send($query);
+ return $this->send($query);
}
-}
\ No newline at end of file
+}
diff --git a/src/Resource/Email.php b/src/Resource/Email.php
index 5746313..a1675a4 100644
--- a/src/Resource/Email.php
+++ b/src/Resource/Email.php
@@ -1,8 +1,19 @@
$query Email address to validate
*
* @return Response The response from the validation request
+ *
+ * @throws TooManyRequestsException
+ * @throws BadRequestException
+ * @throws ForbiddenException
+ * @throws NotFoundException
+ * @throws PaymentRequiredException
+ * @throws ServerErrorException
+ * @throws UnauthorizedException
+ * @throws FoxentryException
+ * @throws GuzzleException
*/
- public function validate($query): Response
+ public function validate(string|array $query): Response
{
- $query = is_array($query) ? $query : ["email" => $query];
+ $query = is_array($query) ? $query : ['email' => $query];
return $this->sendRequest($query);
}
/**
* Search for information related to an email address.
*
- * @param string|array $query Email address to search for
+ * @param string|array $query Email address to search for
*
* @return Response The response from the search request
+ *
+ * @throws TooManyRequestsException
+ * @throws BadRequestException
+ * @throws ForbiddenException
+ * @throws NotFoundException
+ * @throws PaymentRequiredException
+ * @throws ServerErrorException
+ * @throws UnauthorizedException
+ * @throws FoxentryException
+ * @throws GuzzleException
*/
- public function search($query): Response
+ public function search(string|array $query): Response
{
- $query = is_array($query) ? $query : ["value" => $query];
+ $query = is_array($query) ? $query : ['value' => $query];
return $this->sendRequest($query);
}
/**
* Send a request to the API with the given query parameters.
*
- * @param array $query Query parameters for the request
+ * @param array $query Query parameters for the request
*
* @return Response The response from the API
+ *
+ * @throws TooManyRequestsException
+ * @throws BadRequestException
+ * @throws ForbiddenException
+ * @throws NotFoundException
+ * @throws PaymentRequiredException
+ * @throws ServerErrorException
+ * @throws UnauthorizedException
+ * @throws FoxentryException
+ * @throws GuzzleException
*/
private function sendRequest(array $query): Response
{
- return parent::send($query);
+ return $this->send($query);
}
}
diff --git a/src/Resource/Location.php b/src/Resource/Location.php
index 7012f94..f52ca74 100644
--- a/src/Resource/Location.php
+++ b/src/Resource/Location.php
@@ -1,8 +1,19 @@
$query Query parameters for the validation request
+ *
* @return Response The response from the validation request
+ *
+ * @throws TooManyRequestsException
+ * @throws BadRequestException
+ * @throws ForbiddenException
+ * @throws NotFoundException
+ * @throws PaymentRequiredException
+ * @throws ServerErrorException
+ * @throws UnauthorizedException
+ * @throws FoxentryException
+ * @throws GuzzleException
*/
public function validate(array $query): Response
{
@@ -25,9 +47,19 @@ public function validate(array $query): Response
/**
* Search for a location.
*
- * @param array $query Query parameters for the search request
+ * @param array $query Query parameters for the search request
*
* @return Response The response from the API
+ *
+ * @throws TooManyRequestsException
+ * @throws BadRequestException
+ * @throws ForbiddenException
+ * @throws NotFoundException
+ * @throws PaymentRequiredException
+ * @throws ServerErrorException
+ * @throws UnauthorizedException
+ * @throws FoxentryException
+ * @throws GuzzleException
*/
public function search(array $query): Response
{
@@ -37,9 +69,19 @@ public function search(array $query): Response
/**
* Get location details.
*
- * @param array $query Query parameters for the get request
+ * @param array $query Query parameters for the get request
*
* @return Response The response from the API
+ *
+ * @throws TooManyRequestsException
+ * @throws BadRequestException
+ * @throws ForbiddenException
+ * @throws NotFoundException
+ * @throws PaymentRequiredException
+ * @throws ServerErrorException
+ * @throws UnauthorizedException
+ * @throws FoxentryException
+ * @throws GuzzleException
*/
public function get(array $query): Response
{
@@ -49,9 +91,19 @@ public function get(array $query): Response
/**
* Localize a location.
*
- * @param array $query Query parameters for the localize request
+ * @param array $query Query parameters for the localize request
*
* @return Response The response from the API
+ *
+ * @throws TooManyRequestsException
+ * @throws BadRequestException
+ * @throws ForbiddenException
+ * @throws NotFoundException
+ * @throws PaymentRequiredException
+ * @throws ServerErrorException
+ * @throws UnauthorizedException
+ * @throws FoxentryException
+ * @throws GuzzleException
*/
public function localize(array $query): Response
{
@@ -61,12 +113,22 @@ public function localize(array $query): Response
/**
* Send a request to the API with the given query parameters.
*
- * @param array $query Query parameters for the request
+ * @param array $query Query parameters for the request
*
* @return Response The response from the API
+ *
+ * @throws TooManyRequestsException
+ * @throws BadRequestException
+ * @throws ForbiddenException
+ * @throws NotFoundException
+ * @throws PaymentRequiredException
+ * @throws ServerErrorException
+ * @throws UnauthorizedException
+ * @throws FoxentryException
+ * @throws GuzzleException
*/
private function sendRequest(array $query): Response
{
- return parent::send($query);
+ return $this->send($query);
}
-}
\ No newline at end of file
+}
diff --git a/src/Resource/Name.php b/src/Resource/Name.php
index 04c7722..3339118 100644
--- a/src/Resource/Name.php
+++ b/src/Resource/Name.php
@@ -1,8 +1,19 @@
$query Query parameters for the validation request
*
* @return Response The response from the validation request
+ *
+ * @throws TooManyRequestsException
+ * @throws BadRequestException
+ * @throws ForbiddenException
+ * @throws NotFoundException
+ * @throws PaymentRequiredException
+ * @throws ServerErrorException
+ * @throws UnauthorizedException
+ * @throws FoxentryException
+ * @throws GuzzleException
*/
public function validate(array $query): Response
{
@@ -26,12 +47,22 @@ public function validate(array $query): Response
/**
* Send a request to the API with the given query parameters.
*
- * @param array $query Query parameters for the request
+ * @param array $query Query parameters for the request
*
* @return Response The response from the API
+ *
+ * @throws TooManyRequestsException
+ * @throws BadRequestException
+ * @throws ForbiddenException
+ * @throws NotFoundException
+ * @throws PaymentRequiredException
+ * @throws ServerErrorException
+ * @throws UnauthorizedException
+ * @throws FoxentryException
+ * @throws GuzzleException
*/
private function sendRequest(array $query): Response
{
- return parent::send($query);
+ return $this->send($query);
}
}
diff --git a/src/Resource/Phone.php b/src/Resource/Phone.php
index 689f194..57f7fd4 100644
--- a/src/Resource/Phone.php
+++ b/src/Resource/Phone.php
@@ -1,8 +1,19 @@
$query Query parameters for the validation request
*
* @return Response The response from the validation request
+ *
+ * @throws TooManyRequestsException
+ * @throws BadRequestException
+ * @throws ForbiddenException
+ * @throws NotFoundException
+ * @throws PaymentRequiredException
+ * @throws ServerErrorException
+ * @throws UnauthorizedException
+ * @throws FoxentryException
+ * @throws GuzzleException
*/
public function validate(array $query): Response
{
@@ -26,12 +47,22 @@ public function validate(array $query): Response
/**
* Send a request to the API with the given query parameters.
*
- * @param array $query Query parameters for the request
+ * @param array $query Query parameters for the request
*
* @return Response The response from the API
+ *
+ * @throws TooManyRequestsException
+ * @throws BadRequestException
+ * @throws ForbiddenException
+ * @throws NotFoundException
+ * @throws PaymentRequiredException
+ * @throws ServerErrorException
+ * @throws UnauthorizedException
+ * @throws FoxentryException
+ * @throws GuzzleException
*/
private function sendRequest(array $query): Response
{
- return parent::send($query);
+ return $this->send($query);
}
-}
\ No newline at end of file
+}
diff --git a/src/Response.php b/src/Response.php
index f85d347..11f061e 100644
--- a/src/Response.php
+++ b/src/Response.php
@@ -1,5 +1,7 @@
data->status ?? null;
}
@@ -52,7 +52,7 @@ public function getStatus()
/**
* Get headers received from the API response.
*
- * @return array Response headers
+ * @return string[][] Response headers
*/
public function getHeaders(): array
{
@@ -64,8 +64,9 @@ public function getHeaders(): array
*
* @return int Rate limit number
*/
- public function getRateLimit(): int {
- return reset($this->headers['foxentry-rate-limit']);
+ public function getRateLimit(): int
+ {
+ return (int) reset($this->headers['foxentry-rate-limit']);
}
/**
@@ -73,8 +74,9 @@ public function getRateLimit(): int {
*
* @return int Time period in seconds of how long it will take before the rate limit is restored
*/
- public function getRateLimitPeriod(): int {
- return reset($this->headers['foxentry-rate-limit-period']);
+ public function getRateLimitPeriod(): int
+ {
+ return (int) reset($this->headers['foxentry-rate-limit-period']);
}
/**
@@ -82,8 +84,9 @@ public function getRateLimitPeriod(): int {
*
* @return int Remaining rate limit
*/
- public function getRateLimitRemaining(): int {
- return reset($this->headers['foxentry-rate-limit-remaining']);
+ public function getRateLimitRemaining(): int
+ {
+ return (int) reset($this->headers['foxentry-rate-limit-remaining']);
}
/**
@@ -91,12 +94,13 @@ public function getRateLimitRemaining(): int {
*
* @return ?float Remaining daily credits, null if no limit is set
*/
- public function getDailyCreditsLeft(): ?float {
- if (!isset($this->headers['foxentry-daily-credits-left'])){
+ public function getDailyCreditsLeft(): ?float
+ {
+ if (!isset($this->headers['foxentry-daily-credits-left'])) {
return null;
}
- return reset($this->headers['foxentry-daily-credits-left']);
+ return (float) reset($this->headers['foxentry-daily-credits-left']);
}
/**
@@ -104,12 +108,13 @@ public function getDailyCreditsLeft(): ?float {
*
* @return ?int Daily credits limit, null if no limit is set
*/
- public function getDailyCreditsLimit(): ?int {
- if (!isset($this->headers['foxentry-daily-credits-limit'])){
+ public function getDailyCreditsLimit(): ?int
+ {
+ if (!isset($this->headers['foxentry-daily-credits-limit'])) {
return null;
}
- return reset($this->headers['foxentry-daily-credits-limit']);
+ return (int) reset($this->headers['foxentry-daily-credits-limit']);
}
/**
@@ -117,8 +122,9 @@ public function getDailyCreditsLimit(): ?int {
*
* @return float API version
*/
- public function getApiVersion(): float {
- return reset($this->headers['foxentry-api-version']);
+ public function getApiVersion(): float
+ {
+ return (float) reset($this->headers['foxentry-api-version']);
}
/**
@@ -126,7 +132,7 @@ public function getApiVersion(): float {
*
* @return mixed|null The request details or null if not present in the response
*/
- public function getRequest()
+ public function getRequest(): mixed
{
return $this->data->request ?? null;
}
@@ -136,7 +142,7 @@ public function getRequest()
*
* @return mixed|null The response data or null if not present in the response
*/
- public function getResponse()
+ public function getResponse(): mixed
{
return $this->data->response ?? null;
}
@@ -146,11 +152,12 @@ public function getResponse()
*
* @return mixed|null The result or null if not present in the response
*/
- public function getResult()
+ public function getResult(): mixed
{
$result = $this->getResponse()->result ?? null;
- if(empty($result))
+ if (empty($result)) {
$result = $this->getResponse()->results ?? null;
+ }
return $result;
}
@@ -160,7 +167,7 @@ public function getResult()
*
* @return mixed|null The corrected result or null if not present in the response
*/
- public function getResultCorrected()
+ public function getResultCorrected(): mixed
{
return $this->getResponse()->resultCorrected ?? null;
}
@@ -170,7 +177,7 @@ public function getResultCorrected()
*
* @return mixed|null The suggestions or null if not present in the response
*/
- public function getSuggestions()
+ public function getSuggestions(): mixed
{
return $this->getResponse()->suggestions ?? null;
}
@@ -180,7 +187,7 @@ public function getSuggestions()
*
* @return mixed|null The errors or null if not present in the response
*/
- public function getErrors()
+ public function getErrors(): mixed
{
return $this->data->errors ?? null;
}
diff --git a/tests/Base.php b/tests/Base.php
index 7a4aba3..e18f3c9 100644
--- a/tests/Base.php
+++ b/tests/Base.php
@@ -1,4 +1,7 @@
assertNotEmpty($_ENV['API_KEY'], 'You didn\'t set your API key in .env file');
- $this->api = new ApiClient($_ENV['API_KEY']);
+ self::assertNotEmpty($_ENV['API_KEY'], 'You didn\'t set your API key in .env file');
+ self::$api = new ApiClient($_ENV['API_KEY']);
}
}
diff --git a/tests/Unit/Company/CompanyGetTest.php b/tests/Unit/Company/CompanyGetTest.php
index 40ceca1..e6d6a00 100644
--- a/tests/Unit/Company/CompanyGetTest.php
+++ b/tests/Unit/Company/CompanyGetTest.php
@@ -1,6 +1,8 @@
"CZ",
- "registrationNumber" => "04997476"
+ 'country' => 'CZ',
+ 'registrationNumber' => '04997476',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "basic"
+ 'dataScope' => 'basic',
];
// Perform company data retrieval.
- $response = $this->api->company()->setOptions($options)->get($query);
+ $response = self::$api->company()->setOptions($options)->get($query);
$result = $response->getResult();
// Assertions.
@@ -39,21 +41,21 @@ public function testBasicDataScope()
/**
* Test retrieval of extended data scope by country and registration number.
*/
- public function testExtendedDataScope()
+ public function testExtendedDataScope(): void
{
// Query parameters for retrieving company data by country and registration number.
$query = [
- "country" => "CZ",
- "registrationNumber" => "04997476"
+ 'country' => 'CZ',
+ 'registrationNumber' => '04997476',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "extended"
+ 'dataScope' => 'extended',
];
// Perform company data retrieval.
- $response = $this->api->company()->setOptions($options)->get($query);
+ $response = self::$api->company()->setOptions($options)->get($query);
$result = $response->getResult();
// Assertions.
@@ -65,21 +67,21 @@ public function testExtendedDataScope()
/**
* Test retrieval of full data scope by country and registration number.
*/
- public function testFullDataScope()
+ public function testFullDataScope(): void
{
// Query parameters for retrieving company data by country and registration number.
$query = [
- "country" => "CZ",
- "registrationNumber" => "04997476"
+ 'country' => 'CZ',
+ 'registrationNumber' => '04997476',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "full"
+ 'dataScope' => 'full',
];
// Perform company data retrieval.
- $response = $this->api->company()->setOptions($options)->get($query);
+ $response = self::$api->company()->setOptions($options)->get($query);
$result = $response->getResult();
// Assertions.
@@ -91,24 +93,24 @@ public function testFullDataScope()
/**
* Test company data retrieval with custom ID.
*/
- public function testWithCustomId()
+ public function testWithCustomId(): void
{
// Custom ID to identify the request.
$customRequestID = 'MyCustomID';
// Query parameters for company data retrieval.
$query = [
- "country" => "CZ",
- "registrationNumber" => "04997476"
+ 'country' => 'CZ',
+ 'registrationNumber' => '04997476',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "basic"
+ 'dataScope' => 'basic',
];
// Perform company data retrieval.
- $response = $this->api->company()
+ $response = self::$api->company()
->setCustomId($customRequestID)
->setOptions($options)
->get($query);
@@ -124,24 +126,24 @@ public function testWithCustomId()
/**
* Test company data retrieval with client information.
*/
- public function testWithClient()
+ public function testWithClient(): void
{
// Query parameters for company data retrieval.
$query = [
- "country" => "CZ",
- "registrationNumber" => "04997476"
+ 'country' => 'CZ',
+ 'registrationNumber' => '04997476',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "basic"
+ 'dataScope' => 'basic',
];
// Perform company data retrieval with client information.
- $response = $this->api->company()
+ $response = self::$api->company()
->setOptions($options)
- ->setClientCountry("CZ")
- ->setClientIP("127.0.0.1")
+ ->setClientCountry('CZ')
+ ->setClientIP('127.0.0.1')
->setClientLocation(50.073658, 14.418540)
->get($query);
@@ -156,21 +158,21 @@ public function testWithClient()
/**
* Settings should not persist between calls.
*/
- public function testInstanceSettings()
+ public function testInstanceSettings(): void
{
// Name that will be sent to the API for validation.
$query = [
- "country" => "CZ",
- "registrationNumber" => "04997476"
+ 'country' => 'CZ',
+ 'registrationNumber' => '04997476',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "basic"
+ 'dataScope' => 'basic',
];
// Perform name validation with client information.
- $response = $this->api->company()
+ $response = self::$api->company()
->setOptions($options)
->includeRequestDetails()
->get($query);
@@ -180,7 +182,7 @@ public function testInstanceSettings()
$this->assertObjectHasProperty('query', $result);
- $response = $this->api->company()
+ $response = self::$api->company()
->setOptions($options)
->get($query);
diff --git a/tests/Unit/Company/CompanySearchTest.php b/tests/Unit/Company/CompanySearchTest.php
index b904850..c1edfe7 100644
--- a/tests/Unit/Company/CompanySearchTest.php
+++ b/tests/Unit/Company/CompanySearchTest.php
@@ -1,5 +1,7 @@
"name",
- "value" => "Web"
+ 'type' => 'name',
+ 'value' => 'Web',
];
// Options that will be sent within the request.
$options = [
- "resultsLimit" => 10
+ 'resultsLimit' => 10,
];
// Perform company name search.
- $response = $this->api->company()->setOptions($options)->search($query);
+ $response = self::$api->company()->setOptions($options)->search($query);
$result = $response->getResult();
// Assertions.
@@ -41,21 +43,21 @@ public function testSearchName()
/**
* Test valid registration number search.
*/
- public function testSearchRegistrationNumber()
+ public function testSearchRegistrationNumber(): void
{
// Input parameters for registration number search.
$query = [
- "type" => "registrationNumber",
- "value" => "10"
+ 'type' => 'registrationNumber',
+ 'value' => '10',
];
// Options that will be sent within the request.
$options = [
- "resultsLimit" => 10
+ 'resultsLimit' => 10,
];
// Perform registration number search.
- $response = $this->api->company()->setOptions($options)->search($query);
+ $response = self::$api->company()->setOptions($options)->search($query);
$result = $response->getResult();
// Assertions.
@@ -69,21 +71,21 @@ public function testSearchRegistrationNumber()
/**
* Test valid tax number search.
*/
- public function testSearchTaxNumber()
+ public function testSearchTaxNumber(): void
{
// Input parameters for tax number search.
$query = [
- "type" => "taxNumber",
- "value" => "10"
+ 'type' => 'taxNumber',
+ 'value' => '10',
];
// Options that will be sent within the request.
$options = [
- "resultsLimit" => 10
+ 'resultsLimit' => 10,
];
// Perform tax number search.
- $response = $this->api->company()->setOptions($options)->search($query);
+ $response = self::$api->company()->setOptions($options)->search($query);
$result = $response->getResult();
// Assertions.
@@ -97,21 +99,21 @@ public function testSearchTaxNumber()
/**
* Test valid VAT number search.
*/
- public function testSearchVatNumber()
+ public function testSearchVatNumber(): void
{
// Input parameters for VAT number search.
$query = [
- "type" => "vatNumber",
- "value" => "CZ04997476"
+ 'type' => 'vatNumber',
+ 'value' => 'CZ04997476',
];
// Options that will be sent within the request.
$options = [
- "resultsLimit" => 10
+ 'resultsLimit' => 10,
];
// Perform VAT number search.
- $response = $this->api->company()->setOptions($options)->search($query);
+ $response = self::$api->company()->setOptions($options)->search($query);
$result = $response->getResult();
// Assertions.
@@ -125,24 +127,24 @@ public function testSearchVatNumber()
/**
* Test company data search with custom ID.
*/
- public function testWithCustomId()
+ public function testWithCustomId(): void
{
// Custom ID to identify the request.
$customRequestID = 'MyCustomID';
// Input parameters for company name search.
$query = [
- "type" => "name",
- "value" => "Web"
+ 'type' => 'name',
+ 'value' => 'Web',
];
// Options that will be sent within the request.
$options = [
- "resultsLimit" => 10
+ 'resultsLimit' => 10,
];
// Perform company data search.
- $response = $this->api->company()
+ $response = self::$api->company()
->setCustomId($customRequestID)
->setOptions($options)
->search($query);
@@ -160,24 +162,24 @@ public function testWithCustomId()
/**
* Test company data search with client information.
*/
- public function testWithClient()
+ public function testWithClient(): void
{
// Input parameters for company name search.
$query = [
- "type" => "name",
- "value" => "Web"
+ 'type' => 'name',
+ 'value' => 'Web',
];
// Options that will be sent within the request.
$options = [
- "resultsLimit" => 10
+ 'resultsLimit' => 10,
];
// Perform company data search with client information.
- $response = $this->api->company()
+ $response = self::$api->company()
->setOptions($options)
- ->setClientCountry("CZ")
- ->setClientIP("127.0.0.1")
+ ->setClientCountry('CZ')
+ ->setClientIP('127.0.0.1')
->setClientLocation(50.073658, 14.418540)
->search($query);
diff --git a/tests/Unit/Company/CompanyValidateTest.php b/tests/Unit/Company/CompanyValidateTest.php
index 223cb08..9e8e3bd 100644
--- a/tests/Unit/Company/CompanyValidateTest.php
+++ b/tests/Unit/Company/CompanyValidateTest.php
@@ -1,6 +1,8 @@
"AVANTRO s.r.o.",
- "registrationNumber" => "04997476"
+ 'name' => 'AVANTRO s.r.o.',
+ 'registrationNumber' => '04997476',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "basic"
+ 'dataScope' => 'basic',
];
// Perform company data validation.
- $response = $this->api->company()->setOptions($options)->validate($query);
+ $response = self::$api->company()->setOptions($options)->validate($query);
$result = $response->getResult();
// Assertions.
$this->assertInstanceOf(Response::class, $response);
$this->assertEquals(200, $response->getStatus());
$this->assertTrue($result->isValid);
- $this->assertEquals("valid", $result->proposal);
+ $this->assertEquals('valid', $result->proposal);
$this->assertNotEmpty($result->data);
}
/**
* Test invalid company data.
*/
- public function testInvalid()
+ public function testInvalid(): void
{
// Query parameters for validating company data.
$query = [
- "name" => "AVANTRO",
- "registrationNumber" => "25547"
+ 'name' => 'AVANTRO',
+ 'registrationNumber' => '25547',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "basic",
+ 'dataScope' => 'basic',
];
// Perform company data validation.
- $response = $this->api->company()->setOptions($options)->validate($query);
+ $response = self::$api->company()->setOptions($options)->validate($query);
$result = $response->getResult();
// Assertions.
$this->assertInstanceOf(Response::class, $response);
$this->assertEquals(200, $response->getStatus());
$this->assertFalse($result->isValid);
- $this->assertEquals("invalid", $result->proposal);
+ $this->assertEquals('invalid', $result->proposal);
$this->assertNotEmpty($result->errors);
}
/**
* Test invalid company data with correction.
*/
- public function testInvalidWithCorrection()
+ public function testInvalidWithCorrection(): void
{
// Query parameters for validating company data.
$query = [
- "name" => "AVANTRO",
- "registrationNumber" => "04997476"
+ 'name' => 'AVANTRO',
+ 'registrationNumber' => '04997476',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "basic",
+ 'dataScope' => 'basic',
];
// Perform company data validation.
- $response = $this->api->company()->setOptions($options)->validate($query);
+ $response = self::$api->company()->setOptions($options)->validate($query);
$result = $response->getResult();
// Assertions.
$this->assertInstanceOf(Response::class, $response);
$this->assertEquals(200, $response->getStatus());
$this->assertFalse($result->isValid);
- $this->assertEquals("invalidWithCorrection", $result->proposal);
+ $this->assertEquals('invalidWithCorrection', $result->proposal);
$this->assertNotEmpty($response->getResultCorrected());
}
/**
* Test invalid company data with suggestion.
*/
- public function testInvalidWithSuggestion()
+ public function testInvalidWithSuggestion(): void
{
// Query parameters for validating company data.
$query = [
- "registrationNumber" => "0499747"
+ 'registrationNumber' => '0499747',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "basic"
+ 'dataScope' => 'basic',
];
// Perform company data validation.
- $response = $this->api->company()->setOptions($options)->validate($query);
+ $response = self::$api->company()->setOptions($options)->validate($query);
$result = $response->getResult();
// Assertions.
$this->assertInstanceOf(Response::class, $response);
$this->assertEquals(200, $response->getStatus());
$this->assertFalse($result->isValid);
- $this->assertEquals("invalidWithSuggestion", $result->proposal);
+ $this->assertEquals('invalidWithSuggestion', $result->proposal);
$this->assertNotEmpty($response->getSuggestions());
}
/**
* Test company data validation with custom ID.
*/
- public function testWithCustomId()
+ public function testWithCustomId(): void
{
// Custom ID to identify the request.
$customRequestID = 'MyCustomID';
// Query parameters for validating company data.
$query = [
- "name" => "AVANTRO s.r.o.",
- "registrationNumber" => "04997476"
+ 'name' => 'AVANTRO s.r.o.',
+ 'registrationNumber' => '04997476',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "basic"
+ 'dataScope' => 'basic',
];
// Perform company data validation.
- $response = $this->api->company()
+ $response = self::$api->company()
->setCustomId($customRequestID)
->setOptions($options)
->validate($query);
@@ -157,24 +159,24 @@ public function testWithCustomId()
/**
* Test company data validation with client information.
*/
- public function testWithClient()
+ public function testWithClient(): void
{
// Query parameters for validating company data.
$query = [
- "name" => "AVANTRO s.r.o.",
- "registrationNumber" => "04997476"
+ 'name' => 'AVANTRO s.r.o.',
+ 'registrationNumber' => '04997476',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "basic"
+ 'dataScope' => 'basic',
];
// Perform company data validation with client information.
- $response = $this->api->company()
+ $response = self::$api->company()
->setOptions($options)
- ->setClientCountry("CZ")
- ->setClientIP("127.0.0.1")
+ ->setClientCountry('CZ')
+ ->setClientIP('127.0.0.1')
->setClientLocation(50.073658, 14.418540)
->validate($query);
diff --git a/tests/Unit/Email/EmailSearchTest.php b/tests/Unit/Email/EmailSearchTest.php
index 4f01183..ac02347 100644
--- a/tests/Unit/Email/EmailSearchTest.php
+++ b/tests/Unit/Email/EmailSearchTest.php
@@ -1,5 +1,7 @@
5
+ 'resultsLimit' => 5,
];
// Perform email search.
- $response = $this->api->email()->setOptions($options)->search($input);
+ $response = self::$api->email()->setOptions($options)->search($input);
$result = $response->getResult();
// Assertions.
@@ -40,20 +42,20 @@ public function testSearchResults()
/**
* Test email search when the input parameter is specified as the entire query.
*/
- public function testQueryInput()
+ public function testQueryInput(): void
{
// Query that will be sent to the API for validation.
$query = [
- "value" => "info@"
+ 'value' => 'info@',
];
// Options that will be sent within the request.
$options = [
- "resultsLimit" => 5
+ 'resultsLimit' => 5,
];
// Perform email validation.
- $response = $this->api->email()->setOptions($options)->search($query);
+ $response = self::$api->email()->setOptions($options)->search($query);
// Assertions.
$this->assertInstanceOf(Response::class, $response);
diff --git a/tests/Unit/Email/EmailValidateTest.php b/tests/Unit/Email/EmailValidateTest.php
index 92663c2..0c9c2dc 100644
--- a/tests/Unit/Email/EmailValidateTest.php
+++ b/tests/Unit/Email/EmailValidateTest.php
@@ -1,5 +1,7 @@
"extended"
+ 'validationType' => 'extended',
];
// Perform email validation.
- $response = $this->api->email()->setOptions($options)->validate($email);
+ $response = self::$api->email()->setOptions($options)->validate($email);
$result = $response->getResult();
// Assertions.
$this->assertInstanceOf(Response::class, $response);
$this->assertEquals(200, $response->getStatus());
$this->assertTrue($result->isValid);
- $this->assertEquals("valid", $result->proposal);
+ $this->assertEquals('valid', $result->proposal);
$this->assertNotEmpty($result->data);
}
/**
* Test invalid email.
*/
- public function testInvalid()
+ public function testInvalid(): void
{
// Email that will be sent to the API for validation.
- $email = "invalidUser@foxentry.com";
+ $email = 'invalidUser@foxentry.com';
// Options that will be sent within the request.
$options = [
- "validationType" => "extended"
+ 'validationType' => 'extended',
];
// Perform email validation.
- $response = $this->api->email()->setOptions($options)->validate($email);
+ $response = self::$api->email()->setOptions($options)->validate($email);
$result = $response->getResult();
// Assertions.
$this->assertInstanceOf(Response::class, $response);
$this->assertEquals(200, $response->getStatus());
$this->assertFalse($result->isValid);
- $this->assertEquals("invalid", $result->proposal);
+ $this->assertEquals('invalid', $result->proposal);
$this->assertNotEmpty($result->errors);
}
/**
* Test invalid email with suggestion.
*/
- public function testInvalidWithSuggestion()
+ public function testInvalidWithSuggestion(): void
{
// Email that will be sent to the API for validation.
- $email = "info@gmali.com";
+ $email = 'info@gmali.com';
// Options that will be sent within the request.
$options = [
- "validationType" => "extended"
+ 'validationType' => 'extended',
];
// Perform email validation.
- $response = $this->api->email()->setOptions($options)->validate($email);
+ $response = self::$api->email()->setOptions($options)->validate($email);
$result = $response->getResult();
// Assertions.
$this->assertInstanceOf(Response::class, $response);
$this->assertEquals(200, $response->getStatus());
$this->assertFalse($result->isValid);
- $this->assertEquals("invalidWithSuggestion", $result->proposal);
+ $this->assertEquals('invalidWithSuggestion', $result->proposal);
$this->assertNotEmpty($response->getSuggestions());
}
/**
* Test invalid email with correction.
*/
- public function testInvalidWithCorrection()
+ public function testInvalidWithCorrection(): void
{
// Email that will be sent to the API for validation.
- $email = "info@foxentry,com"; // Notice the "," instead of "." before the com
+ $email = 'info@foxentry,com'; // Notice the "," instead of "." before the com
// Options that will be sent within the request.
$options = [
- "validationType" => "extended"
+ 'validationType' => 'extended',
];
// Perform email validation.
- $response = $this->api->email()->setOptions($options)->validate($email);
+ $response = self::$api->email()->setOptions($options)->validate($email);
$result = $response->getResult();
// Assertions.
$this->assertInstanceOf(Response::class, $response);
$this->assertEquals(200, $response->getStatus());
$this->assertFalse($result->isValid);
- $this->assertEquals("invalidWithCorrection", $result->proposal);
+ $this->assertEquals('invalidWithCorrection', $result->proposal);
$this->assertNotEmpty($response->getResultCorrected());
}
/**
* Test invalid email with partial correction.
*/
- public function testInvalidWithPartialCorrection()
+ public function testInvalidWithPartialCorrection(): void
{
// Email that will be sent to the API for validation.
- $email = "infogmail.com";
+ $email = 'infogmail.com';
// Options that will be sent within the request.
$options = [
- "validationType" => "extended"
+ 'validationType' => 'extended',
];
// Perform email validation.
- $response = $this->api->email()->setOptions($options)->validate($email);
+ $response = self::$api->email()->setOptions($options)->validate($email);
$result = $response->getResult();
// Assertions.
$this->assertInstanceOf(Response::class, $response);
$this->assertEquals(200, $response->getStatus());
$this->assertFalse($result->isValid);
- $this->assertEquals("invalidWithPartialCorrection", $result->proposal);
+ $this->assertEquals('invalidWithPartialCorrection', $result->proposal);
$this->assertNotEmpty($response->getResultCorrected());
}
/**
* Test disallowed disposable email.
*/
- public function testDisallowedDisposable()
+ public function testDisallowedDisposable(): void
{
// Email that will be sent to the API for validation.
- $email = "rasini3451@naymedia.com";
+ $email = 'rasini3451@naymedia.com';
// Options that will be sent within the request.
$options = [
- "acceptDisposableEmails" => false,
+ 'acceptDisposableEmails' => false,
];
// Perform email validation.
- $response = $this->api->email()->setOptions($options)->validate($email);
+ $response = self::$api->email()->setOptions($options)->validate($email);
$result = $response->getResult();
// Assertions.
$this->assertInstanceOf(Response::class, $response);
$this->assertEquals(200, $response->getStatus());
$this->assertFalse($result->isValid);
- $this->assertEquals("invalid", $result->proposal);
+ $this->assertEquals('invalid', $result->proposal);
$this->assertTrue($result->flags->isDisposableEmailAddress);
$this->assertNotEmpty($result->errors);
}
@@ -164,25 +166,25 @@ public function testDisallowedDisposable()
/**
* Test disallowed freemail.
*/
- public function testDisallowedFreemails()
+ public function testDisallowedFreemails(): void
{
// Email that will be sent to the API for validation.
- $email = "info@gmail.com";
+ $email = 'info@gmail.com';
// Options that will be sent within the request.
$options = [
- "acceptFreemails" => false,
+ 'acceptFreemails' => false,
];
// Perform email validation.
- $response = $this->api->email()->setOptions($options)->validate($email);
+ $response = self::$api->email()->setOptions($options)->validate($email);
$result = $response->getResult();
// Assertions.
$this->assertInstanceOf(Response::class, $response);
$this->assertEquals(200, $response->getStatus());
$this->assertFalse($result->isValid);
- $this->assertEquals("invalid", $result->proposal);
+ $this->assertEquals('invalid', $result->proposal);
$this->assertTrue($result->flags->isFreemail);
$this->assertNotEmpty($result->errors);
}
@@ -190,7 +192,7 @@ public function testDisallowedFreemails()
/**
* Test email validation with custom ID.
*/
- public function testWithCustomId()
+ public function testWithCustomId(): void
{
// Custom ID to identify the request.
$customRequestID = 'orderEmailValidation';
@@ -199,7 +201,7 @@ public function testWithCustomId()
$email = 'info@foxentry.com';
// Perform email validation.
- $response = $this->api->email()
+ $response = self::$api->email()
->setCustomId($customRequestID)
->validate($email);
@@ -214,15 +216,15 @@ public function testWithCustomId()
/**
* Test email validation with client information.
*/
- public function testWithClient()
+ public function testWithClient(): void
{
// Email that will be sent to the API for validation.
$email = 'info@foxentry.com';
// Perform email validation with client information.
- $response = $this->api->email()
- ->setClientCountry("CZ")
- ->setClientIP("127.0.0.1")
+ $response = self::$api->email()
+ ->setClientCountry('CZ')
+ ->setClientIP('127.0.0.1')
->setClientLocation(50.073658, 14.418540)
->validate($email);
@@ -237,20 +239,20 @@ public function testWithClient()
/**
* Test email validation when the input parameter is specified as the entire query.
*/
- public function testQueryInput()
+ public function testQueryInput(): void
{
// Query that will be sent to the API for validation.
$query = [
- "email" => "info@foxentry.com"
+ 'email' => 'info@foxentry.com',
];
// Options that will be sent within the request.
$options = [
- "validationType" => "extended"
+ 'validationType' => 'extended',
];
// Perform email validation.
- $response = $this->api->email()->setOptions($options)->validate($query);
+ $response = self::$api->email()->setOptions($options)->validate($query);
// Assertions.
$this->assertInstanceOf(Response::class, $response);
@@ -260,18 +262,18 @@ public function testQueryInput()
/**
* Test of receiving response headers
*/
- public function testResponseHeaders()
+ public function testResponseHeaders(): void
{
// Email that will be sent to the API for validation.
- $email = "info@foxentry.com";
+ $email = 'info@foxentry.com';
// Options that will be sent within the request.
$options = [
- "validationType" => "extended"
+ 'validationType' => 'extended',
];
// Perform email validation and get headers of the response.
- $response = $this->api->email()->setOptions($options)->validate($email);
+ $response = self::$api->email()->setOptions($options)->validate($email);
$headers = $response->getHeaders();
$rateLimit = $response->getRateLimit();
$rateLimitPeriod = $response->getRateLimitPeriod();
@@ -290,13 +292,13 @@ public function testResponseHeaders()
/**
* Settings should not persist between calls.
*/
- public function testInstanceSettings()
+ public function testInstanceSettings(): void
{
// Name that will be sent to the API for validation.
- $email = "info@foxentry.com";
+ $email = 'info@foxentry.com';
// Perform name validation with client information.
- $response = $this->api->email()
+ $response = self::$api->email()
->includeRequestDetails()
->validate($email);
@@ -305,7 +307,7 @@ public function testInstanceSettings()
$this->assertObjectHasProperty('query', $result);
- $response = $this->api->email()
+ $response = self::$api->email()
->validate($email);
$result = $response->getRequest();
diff --git a/tests/Unit/Location/LocationGetTest.php b/tests/Unit/Location/LocationGetTest.php
index d8721d0..208499d 100644
--- a/tests/Unit/Location/LocationGetTest.php
+++ b/tests/Unit/Location/LocationGetTest.php
@@ -1,5 +1,7 @@
"CZ",
- "id" => "d2ade877-1e95-4a83-baa6-5431ce5b3ca8"
+ 'country' => 'CZ',
+ 'id' => 'd2ade877-1e95-4a83-baa6-5431ce5b3ca8',
];
// Options that will be sent within the request.
$options = [
- "idType" => "internal",
- "dataScope" => "full"
+ 'idType' => 'internal',
+ 'dataScope' => 'full',
];
// Perform location data retrieval.
- $response = $this->api->location()->setOptions($options)->get($query);
+ $response = self::$api->location()->setOptions($options)->get($query);
$result = $response->getResult();
// Assertions.
@@ -40,22 +42,22 @@ public function testGetFullDataScopeByInternalID()
/**
* Test retrieval of full data scope by external ID.
*/
- public function getFullDataScopeByExternalID()
+ public function getFullDataScopeByExternalID(): void
{
// Query parameters for retrieving location data by external ID.
$query = [
- "country" => "CZ",
- "id" => "22349995"
+ 'country' => 'CZ',
+ 'id' => '22349995',
];
// Options that will be sent within the request.
$options = [
- "idType" => "external",
- "dataScope" => "full"
+ 'idType' => 'external',
+ 'dataScope' => 'full',
];
// Perform location data retrieval.
- $response = $this->api->location()->setOptions($options)->get($query);
+ $response = self::$api->location()->setOptions($options)->get($query);
$result = $response->getResult();
// Assertions.
@@ -67,25 +69,25 @@ public function getFullDataScopeByExternalID()
/**
* Test location data retrieval with custom ID.
*/
- public function testWithCustomId()
+ public function testWithCustomId(): void
{
// Custom ID to identify the request.
$customRequestID = 'MyCustomID';
// Query parameters for location data retrieval.
$query = [
- "country" => "CZ",
- "id" => "22349995"
+ 'country' => 'CZ',
+ 'id' => '22349995',
];
// Options that will be sent within the request.
$options = [
- "idType" => "external",
- "dataScope" => "full"
+ 'idType' => 'external',
+ 'dataScope' => 'full',
];
// Perform location data retrieval.
- $response = $this->api->location()
+ $response = self::$api->location()
->setCustomId($customRequestID)
->setOptions($options)
->get($query);
@@ -101,25 +103,25 @@ public function testWithCustomId()
/**
* Test location data retrieval with client information.
*/
- public function testWithClient()
+ public function testWithClient(): void
{
// Query parameters for location data retrieval.
$query = [
- "country" => "CZ",
- "id" => "22349995"
+ 'country' => 'CZ',
+ 'id' => '22349995',
];
// Options that will be sent within the request.
$options = [
- "idType" => "external",
- "dataScope" => "full"
+ 'idType' => 'external',
+ 'dataScope' => 'full',
];
// Perform location data retrieval with client information.
- $response = $this->api->location()
+ $response = self::$api->location()
->setOptions($options)
- ->setClientCountry("CZ")
- ->setClientIP("127.0.0.1")
+ ->setClientCountry('CZ')
+ ->setClientIP('127.0.0.1')
->setClientLocation(50.073658, 14.418540)
->get($query);
@@ -134,22 +136,22 @@ public function testWithClient()
/**
* Settings should not persist between calls.
*/
- public function testInstanceSettings()
+ public function testInstanceSettings(): void
{
// Name that will be sent to the API for validation.
$query = [
- "country" => "CZ",
- "id" => "22349995"
+ 'country' => 'CZ',
+ 'id' => '22349995',
];
// Options that will be sent within the request.
$options = [
- "idType" => "external",
- "dataScope" => "basic"
+ 'idType' => 'external',
+ 'dataScope' => 'basic',
];
// Perform name validation with client information.
- $response = $this->api->location()
+ $response = self::$api->location()
->setOptions($options)
->includeRequestDetails()
->get($query);
@@ -159,7 +161,7 @@ public function testInstanceSettings()
$this->assertObjectHasProperty('query', $result);
- $response = $this->api->location()
+ $response = self::$api->location()
->setOptions($options)
->get($query);
diff --git a/tests/Unit/Location/LocationLocalizeTest.php b/tests/Unit/Location/LocationLocalizeTest.php
index ae670d6..ad52781 100644
--- a/tests/Unit/Location/LocationLocalizeTest.php
+++ b/tests/Unit/Location/LocationLocalizeTest.php
@@ -1,5 +1,7 @@
50.0919999,
- "lon" => 14.4527403
+ 'lat' => 50.0919999,
+ 'lon' => 14.4527403,
];
// Options that will be sent within the request.
$options = [
- "resultsLimit" => 10,
- "radius" => 15,
- "acceptNearest" => false
+ 'resultsLimit' => 10,
+ 'radius' => 15,
+ 'acceptNearest' => false,
];
// Perform location data localization.
- $response = $this->api->location()->setOptions($options)->localize($query);
+ $response = self::$api->location()->setOptions($options)->localize($query);
$result = $response->getResult();
// Assertions.
@@ -43,26 +45,26 @@ public function testLocalizationResults()
/**
* Test location data localization with custom ID.
*/
- public function testWithCustomId()
+ public function testWithCustomId(): void
{
// Custom ID to identify the request.
$customRequestID = 'MyCustomID';
// Query parameters for localizing location data.
$query = [
- "lat" => 50.0919999,
- "lon" => 14.4527403
+ 'lat' => 50.0919999,
+ 'lon' => 14.4527403,
];
// Options that will be sent within the request.
$options = [
- "resultsLimit" => 10,
- "radius" => 15,
- "acceptNearest" => false
+ 'resultsLimit' => 10,
+ 'radius' => 15,
+ 'acceptNearest' => false,
];
// Perform location data localization.
- $response = $this->api->location()
+ $response = self::$api->location()
->setCustomId($customRequestID)
->setOptions($options)
->localize($query);
@@ -80,26 +82,26 @@ public function testWithCustomId()
/**
* Test location data localization with client information.
*/
- public function testWithClient()
+ public function testWithClient(): void
{
// Query parameters for localizing location data.
$query = [
- "lat" => 50.0919999,
- "lon" => 14.4527403
+ 'lat' => 50.0919999,
+ 'lon' => 14.4527403,
];
// Options that will be sent within the request.
$options = [
- "resultsLimit" => 10,
- "radius" => 15,
- "acceptNearest" => false
+ 'resultsLimit' => 10,
+ 'radius' => 15,
+ 'acceptNearest' => false,
];
// Perform location data localization with client information.
- $response = $this->api->location()
+ $response = self::$api->location()
->setOptions($options)
- ->setClientCountry("CZ")
- ->setClientIP("127.0.0.1")
+ ->setClientCountry('CZ')
+ ->setClientIP('127.0.0.1')
->setClientLocation(50.073658, 14.418540)
->localize($query);
diff --git a/tests/Unit/Location/LocationSearchTest.php b/tests/Unit/Location/LocationSearchTest.php
index f63356a..9774d1a 100644
--- a/tests/Unit/Location/LocationSearchTest.php
+++ b/tests/Unit/Location/LocationSearchTest.php
@@ -1,5 +1,7 @@
"street",
- "value" => "tha"
+ 'type' => 'street',
+ 'value' => 'tha',
];
// Options that will be sent within the request.
$options = [
- "resultsLimit" => 10
+ 'resultsLimit' => 10,
];
// Perform street search.
- $response = $this->api->location()->setOptions($options)->search($query);
+ $response = self::$api->location()->setOptions($options)->search($query);
$result = $response->getResult();
// Assertions.
@@ -41,21 +43,21 @@ public function testSearchStreet()
/**
* Test valid city search.
*/
- public function testSearchCity()
+ public function testSearchCity(): void
{
// Input parameters for city search.
$query = [
- "type" => "city",
- "value" => "pra"
+ 'type' => 'city',
+ 'value' => 'pra',
];
// Options that will be sent within the request.
$options = [
- "resultsLimit" => 10
+ 'resultsLimit' => 10,
];
// Perform city search.
- $response = $this->api->location()->setOptions($options)->search($query);
+ $response = self::$api->location()->setOptions($options)->search($query);
$result = $response->getResult();
// Assertions.
@@ -69,21 +71,21 @@ public function testSearchCity()
/**
* Test valid street with number search.
*/
- public function testSearchStreetWithNumber()
+ public function testSearchStreetWithNumber(): void
{
// Input parameters for street with number search.
$query = [
- "type" => "streetWithNumber",
- "value" => "Jeseniova 56"
+ 'type' => 'streetWithNumber',
+ 'value' => 'Jeseniova 56',
];
// Options that will be sent within the request.
$options = [
- "resultsLimit" => 10
+ 'resultsLimit' => 10,
];
// Perform street with number search.
- $response = $this->api->location()->setOptions($options)->search($query);
+ $response = self::$api->location()->setOptions($options)->search($query);
$result = $response->getResult();
// Assertions.
@@ -97,21 +99,21 @@ public function testSearchStreetWithNumber()
/**
* Test valid ZIP code search.
*/
- public function testSearchZip()
+ public function testSearchZip(): void
{
// Input parameters for ZIP code search.
$query = [
- "type" => "zip",
- "value" => "1"
+ 'type' => 'zip',
+ 'value' => '1',
];
// Options that will be sent within the request.
$options = [
- "resultsLimit" => 10
+ 'resultsLimit' => 10,
];
// Perform ZIP code search.
- $response = $this->api->location()->setOptions($options)->search($query);
+ $response = self::$api->location()->setOptions($options)->search($query);
$result = $response->getResult();
// Assertions.
@@ -125,21 +127,21 @@ public function testSearchZip()
/**
* Test valid full address search.
*/
- public function testSearchFull()
+ public function testSearchFull(): void
{
// Input parameters for full location search.
$query = [
- "type" => "full",
- "value" => "Jeseniova Praha"
+ 'type' => 'full',
+ 'value' => 'Jeseniova Praha',
];
// Options that will be sent within the request.
$options = [
- "resultsLimit" => 10
+ 'resultsLimit' => 10,
];
// Perform full location search.
- $response = $this->api->location()->setOptions($options)->search($query);
+ $response = self::$api->location()->setOptions($options)->search($query);
$result = $response->getResult();
// Assertions.
@@ -153,24 +155,24 @@ public function testSearchFull()
/**
* Test location data validation with custom ID.
*/
- public function testWithCustomId()
+ public function testWithCustomId(): void
{
// Custom ID to identify the request.
$customRequestID = 'MyCustomID';
// Input parameters for street search.
$query = [
- "type" => "street",
- "value" => "tha"
+ 'type' => 'street',
+ 'value' => 'tha',
];
// Options that will be sent within the request.
$options = [
- "resultsLimit" => 10
+ 'resultsLimit' => 10,
];
// Perform location data validation.
- $response = $this->api->location()
+ $response = self::$api->location()
->setCustomId($customRequestID)
->setOptions($options)
->search($query);
@@ -188,24 +190,24 @@ public function testWithCustomId()
/**
* Test location data validation with client information.
*/
- public function testWithClient()
+ public function testWithClient(): void
{
// Input parameters for street search.
$query = [
- "type" => "street",
- "value" => "tha"
+ 'type' => 'street',
+ 'value' => 'tha',
];
// Options that will be sent within the request.
$options = [
- "resultsLimit" => 10
+ 'resultsLimit' => 10,
];
// Perform location data validation with client information.
- $response = $this->api->location()
+ $response = self::$api->location()
->setOptions($options)
- ->setClientCountry("CZ")
- ->setClientIP("127.0.0.1")
+ ->setClientCountry('CZ')
+ ->setClientIP('127.0.0.1')
->setClientLocation(50.073658, 14.418540)
->search($query);
diff --git a/tests/Unit/Location/LocationValidateTest.php b/tests/Unit/Location/LocationValidateTest.php
index e358213..153d484 100644
--- a/tests/Unit/Location/LocationValidateTest.php
+++ b/tests/Unit/Location/LocationValidateTest.php
@@ -1,5 +1,7 @@
"Thámova 137/16",
- "city" => "Praha",
- "zip" => "186 00"
+ 'streetWithNumber' => 'Thámova 137/16',
+ 'city' => 'Praha',
+ 'zip' => '186 00',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "basic",
- "cityFormat" => "minimal",
- "zipFormat" => true
+ 'dataScope' => 'basic',
+ 'cityFormat' => 'minimal',
+ 'zipFormat' => true,
];
// Perform location data validation.
- $response = $this->api->location()->setOptions($options)->validate($query);
+ $response = self::$api->location()->setOptions($options)->validate($query);
$result = $response->getResult();
// Assertions.
$this->assertInstanceOf(Response::class, $response);
$this->assertEquals(200, $response->getStatus());
$this->assertTrue($result->isValid);
- $this->assertEquals("valid", $result->proposal);
+ $this->assertEquals('valid', $result->proposal);
$this->assertNotEmpty($result->data);
}
/**
* Test invalid location data.
*/
- public function testInvalid()
+ public function testInvalid(): void
{
// Query parameters for validating location data.
$query = [
- "streetWithNumber" => "Thámova 123456789",
- "city" => "Parharlin",
- "zip" => "457545754"
+ 'streetWithNumber' => 'Thámova 123456789',
+ 'city' => 'Parharlin',
+ 'zip' => '457545754',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "basic",
- "cityFormat" => "minimal",
- "zipFormat" => true
+ 'dataScope' => 'basic',
+ 'cityFormat' => 'minimal',
+ 'zipFormat' => true,
];
// Perform location data validation.
- $response = $this->api->location()->setOptions($options)->validate($query);
+ $response = self::$api->location()->setOptions($options)->validate($query);
$result = $response->getResult();
// Assertions.
$this->assertInstanceOf(Response::class, $response);
$this->assertEquals(200, $response->getStatus());
$this->assertFalse($result->isValid);
- $this->assertEquals("invalid", $result->proposal);
+ $this->assertEquals('invalid', $result->proposal);
$this->assertNotEmpty($result->errors);
}
/**
* Test invalid location data with correction.
*/
- public function testInvalidWithCorrection()
+ public function testInvalidWithCorrection(): void
{
// Query parameters for validating location data.
$query = [
- "streetWithNumber" => "Thámova 137",
- "city" => "Praha",
- "zip" => "18600"
+ 'streetWithNumber' => 'Thámova 137',
+ 'city' => 'Praha',
+ 'zip' => '18600',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "basic",
- "cityFormat" => "minimal",
- "zipFormat" => true
+ 'dataScope' => 'basic',
+ 'cityFormat' => 'minimal',
+ 'zipFormat' => true,
];
// Perform location data validation.
- $response = $this->api->location()->setOptions($options)->validate($query);
+ $response = self::$api->location()->setOptions($options)->validate($query);
$result = $response->getResult();
// Assertions.
$this->assertInstanceOf(Response::class, $response);
$this->assertEquals(200, $response->getStatus());
$this->assertFalse($result->isValid);
- $this->assertEquals("invalidWithCorrection", $result->proposal);
+ $this->assertEquals('invalidWithCorrection', $result->proposal);
$this->assertNotEmpty($response->getResultCorrected());
}
/**
* Test invalid location data with suggestion.
*/
- public function testInvalidWithSuggestion()
+ public function testInvalidWithSuggestion(): void
{
// Query parameters for validating location data.
$query = [
- "streetWithNumber" => "Olšanská 2898/4",
- "city" => "Praha",
- "zip" => "130 00"
+ 'streetWithNumber' => 'Olšanská 2898/4',
+ 'city' => 'Praha',
+ 'zip' => '130 00',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "basic",
- "cityFormat" => "minimal",
- "zipFormat" => true
+ 'dataScope' => 'basic',
+ 'cityFormat' => 'minimal',
+ 'zipFormat' => true,
];
// Perform location data validation.
- $response = $this->api->location()->setOptions($options)->validate($query);
+ $response = self::$api->location()->setOptions($options)->validate($query);
$result = $response->getResult();
// Assertions.
$this->assertInstanceOf(Response::class, $response);
$this->assertEquals(200, $response->getStatus());
$this->assertFalse($result->isValid);
- $this->assertEquals("invalidWithSuggestion", $result->proposal);
+ $this->assertEquals('invalidWithSuggestion', $result->proposal);
$this->assertNotEmpty($response->getSuggestions());
}
/**
* Test location data validation with custom ID.
*/
- public function testWithCustomId()
+ public function testWithCustomId(): void
{
// Custom ID to identify the request.
$customRequestID = 'MyCustomID';
// Query parameters for validating location data.
$query = [
- "streetWithNumber" => "Thámova 123456789",
- "city" => "Parharlin",
- "zip" => "457545754"
+ 'streetWithNumber' => 'Thámova 123456789',
+ 'city' => 'Parharlin',
+ 'zip' => '457545754',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "basic",
- "cityFormat" => "minimal",
- "zipFormat" => true
+ 'dataScope' => 'basic',
+ 'cityFormat' => 'minimal',
+ 'zipFormat' => true,
];
// Perform location data validation.
- $response = $this->api->location()
+ $response = self::$api->location()
->setCustomId($customRequestID)
->setOptions($options)
->validate($query);
@@ -173,27 +175,27 @@ public function testWithCustomId()
/**
* Test location data validation with client information.
*/
- public function testWithClient()
+ public function testWithClient(): void
{
// Query parameters for validating location data.
$query = [
- "streetWithNumber" => "Thámova 137/16",
- "city" => "Praha",
- "zip" => "186 00"
+ 'streetWithNumber' => 'Thámova 137/16',
+ 'city' => 'Praha',
+ 'zip' => '186 00',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "basic",
- "cityFormat" => "minimal",
- "zipFormat" => true
+ 'dataScope' => 'basic',
+ 'cityFormat' => 'minimal',
+ 'zipFormat' => true,
];
// Perform location data validation with client information.
- $response = $this->api->location()
+ $response = self::$api->location()
->setOptions($options)
- ->setClientCountry("CZ")
- ->setClientIP("127.0.0.1")
+ ->setClientCountry('CZ')
+ ->setClientIP('127.0.0.1')
->setClientLocation(50.073658, 14.418540)
->validate($query);
diff --git a/tests/Unit/Name/NameValidateTest.php b/tests/Unit/Name/NameValidateTest.php
index 7c25558..7123723 100644
--- a/tests/Unit/Name/NameValidateTest.php
+++ b/tests/Unit/Name/NameValidateTest.php
@@ -1,5 +1,7 @@
"Pavel"
+ 'name' => 'Pavel',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "basic"
+ 'dataScope' => 'basic',
];
// Perform name validation.
- $response = $this->api->name()->setOptions($options)->validate($query);
+ $response = self::$api->name()->setOptions($options)->validate($query);
$result = $response->getResult();
// Assertions.
$this->assertInstanceOf(Response::class, $response);
$this->assertEquals(200, $response->getStatus());
$this->assertTrue($result->isValid);
- $this->assertEquals("valid", $result->proposal);
+ $this->assertEquals('valid', $result->proposal);
$this->assertNotEmpty($result->data);
}
/**
* Test invalid name.
*/
- public function testInvalid()
+ public function testInvalid(): void
{
// Name that will be sent to the API for validation.
$query = [
- "name" => "Paeeewas"
+ 'name' => 'Paeeewas',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "basic",
- "validationDepth" => "strict"
+ 'dataScope' => 'basic',
+ 'validationDepth' => 'strict',
];
// Perform name validation.
- $response = $this->api->name()->setOptions($options)->validate($query);
+ $response = self::$api->name()->setOptions($options)->validate($query);
$result = $response->getResult();
// Assertions.
$this->assertInstanceOf(Response::class, $response);
$this->assertEquals(200, $response->getStatus());
$this->assertFalse($result->isValid);
- $this->assertEquals("invalid", $result->proposal);
+ $this->assertEquals('invalid', $result->proposal);
$this->assertNotEmpty($result->errors);
}
/**
* Test invalid name with correction.
*/
- public function testInvalidWithCorrection()
+ public function testInvalidWithCorrection(): void
{
// Name that will be sent to the API for validation.
$query = [
- "name" => "Palve"
+ 'name' => 'Palve',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "basic",
- "validationDepth" => "strict"
+ 'dataScope' => 'basic',
+ 'validationDepth' => 'strict',
];
// Perform name validation.
- $response = $this->api->name()->setOptions($options)->validate($query);
+ $response = self::$api->name()->setOptions($options)->validate($query);
$result = $response->getResult();
// Assertions.
$this->assertInstanceOf(Response::class, $response);
$this->assertEquals(200, $response->getStatus());
$this->assertFalse($result->isValid);
- $this->assertEquals("invalidWithCorrection", $result->proposal);
+ $this->assertEquals('invalidWithCorrection', $result->proposal);
$this->assertNotEmpty($response->getResultCorrected());
}
/**
* Test valid full name validation.
*/
- public function tesValidNameSurnameFullDataScope()
+ public function tesValidNameSurnameFullDataScope(): void
{
// Full name that will be sent to the API for validation.
$query = [
- "nameSurname" => "Pavel Novák"
+ 'nameSurname' => 'Pavel Novák',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "full"
+ 'dataScope' => 'full',
];
// Perform full name validation.
- $response = $this->api->name()->setOptions($options)->validate($query);
+ $response = self::$api->name()->setOptions($options)->validate($query);
$result = $response->getResult();
// Assertions.
$this->assertInstanceOf(Response::class, $response);
$this->assertEquals(200, $response->getStatus());
$this->assertFalse($result->isValid);
- $this->assertEquals("valid", $result->proposal);
+ $this->assertEquals('valid', $result->proposal);
$this->assertNotEmpty($result->details);
}
/**
* Test name validation with custom ID.
*/
- public function testWithCustomId()
+ public function testWithCustomId(): void
{
// Custom ID to identify the request.
$customRequestID = 'MyCustomID';
// Name that will be sent to the API for validation.
$query = [
- "name" => "Pavel"
+ 'name' => 'Pavel',
];
// Perform name validation.
- $response = $this->api->name()
+ $response = self::$api->name()
->setCustomId($customRequestID)
->validate($query);
@@ -149,23 +151,23 @@ public function testWithCustomId()
/**
* Test name validation with client information.
*/
- public function testWithClient()
+ public function testWithClient(): void
{
// Name that will be sent to the API for validation.
$query = [
- "name" => "Pavel"
+ 'name' => 'Pavel',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "basic"
+ 'dataScope' => 'basic',
];
// Perform name validation with client information.
- $response = $this->api->name()
+ $response = self::$api->name()
->setOptions($options)
- ->setClientCountry("CZ")
- ->setClientIP("127.0.0.1")
+ ->setClientCountry('CZ')
+ ->setClientIP('127.0.0.1')
->setClientLocation(50.073658, 14.418540)
->validate($query);
@@ -180,20 +182,20 @@ public function testWithClient()
/**
* Settings should not persist between calls.
*/
- public function testInstanceSettings()
+ public function testInstanceSettings(): void
{
// Name that will be sent to the API for validation.
$query = [
- "name" => "Pavel"
+ 'name' => 'Pavel',
];
// Options that will be sent within the request.
$options = [
- "dataScope" => "basic"
+ 'dataScope' => 'basic',
];
// Perform name validation with client information.
- $response = $this->api->name()
+ $response = self::$api->name()
->setOptions($options)
->includeRequestDetails()
->validate($query);
@@ -203,7 +205,7 @@ public function testInstanceSettings()
$this->assertObjectHasProperty('query', $result);
- $response = $this->api->name()
+ $response = self::$api->name()
->setOptions($options)
->validate($query);
diff --git a/tests/Unit/Phone/PhoneValidateTest.php b/tests/Unit/Phone/PhoneValidateTest.php
index dde82c4..b2daa9d 100644
--- a/tests/Unit/Phone/PhoneValidateTest.php
+++ b/tests/Unit/Phone/PhoneValidateTest.php
@@ -1,5 +1,7 @@
"+420607123456"
+ 'numberWithPrefix' => '+420607123456',
];
// Options that will be sent within the request.
$options = [
- "validationType" => "extended"
+ 'validationType' => 'extended',
];
// Perform phone number validation.
- $response = $this->api->phone()->setOptions($options)->validate($query);
+ $response = self::$api->phone()->setOptions($options)->validate($query);
$result = $response->getResult();
// Assertions.
- $this->assertInstanceOf(Response::class, $response);
- $this->assertEquals(200, $response->getStatus());
- $this->assertTrue($result->isValid);
- $this->assertEquals("valid", $result->proposal);
- $this->assertNotEmpty($result->data);
+ self::assertInstanceOf(Response::class, $response);
+ self::assertEquals(200, $response->getStatus());
+ self::assertTrue($result->isValid);
+ self::assertEquals('valid', $result->proposal);
+ self::assertNotEmpty($result->data);
}
/**
* Test invalid phone number.
*/
- public function testInvalid()
+ public function testInvalid(): void
{
// Phone number with prefix that will be sent to the API for validation.
$query = [
- "numberWithPrefix" => "+42060712345"
+ 'numberWithPrefix' => '+42060712345',
];
// Options that will be sent within the request.
$options = [
- "validationType" => "extended"
+ 'validationType' => 'extended',
];
// Perform phone number validation.
- $response = $this->api->phone()->setOptions($options)->validate($query);
+ $response = self::$api->phone()->setOptions($options)->validate($query);
$result = $response->getResult();
// Assertions.
- $this->assertInstanceOf(Response::class, $response);
- $this->assertEquals(200, $response->getStatus());
- $this->assertFalse($result->isValid);
- $this->assertEquals("invalid", $result->proposal);
- $this->assertNotEmpty($result->errors);
+ self::assertInstanceOf(Response::class, $response);
+ self::assertEquals(200, $response->getStatus());
+ self::assertFalse($result->isValid);
+ self::assertEquals('invalid', $result->proposal);
+ self::assertNotEmpty($result->errors);
}
/**
* Test valid phone number with suggestion.
*/
- public function testValidWithSuggestion()
+ public function testValidWithSuggestion(): void
{
// Phone number and prefix that will be sent to the API for validation.
$query = [
- "prefix" => "+48",
- "number" => "728984101"
+ 'prefix' => '+48',
+ 'number' => '728984101',
];
// Options that will be sent within the request.
$options = [
- "validationType" => "extended"
+ 'validationType' => 'extended',
];
// Perform phone number validation.
- $response = $this->api->phone()->setOptions($options)->validate($query);
+ $response = self::$api->phone()->setOptions($options)->validate($query);
$result = $response->getResult();
// Assertions.
- $this->assertInstanceOf(Response::class, $response);
- $this->assertEquals(200, $response->getStatus());
- $this->assertTrue($result->isValid);
- $this->assertEquals("validWithSuggestion", $result->proposal);
- $this->assertNotEmpty($response->getSuggestions());
+ self::assertInstanceOf(Response::class, $response);
+ self::assertEquals(200, $response->getStatus());
+ self::assertTrue($result->isValid);
+ self::assertEquals('validWithSuggestion', $result->proposal);
+ self::assertNotEmpty($response->getSuggestions());
}
/**
* Test invalid phone number with correction.
*/
- public function testInvalidWithCorrection()
+ public function testInvalidWithCorrection(): void
{
// Phone number and prefix that will be sent to the API for validation.
$query = [
- "prefix" => "+421",
- "number" => "607123456"
+ 'prefix' => '+421',
+ 'number' => '607123456',
];
// Options that will be sent within the request.
$options = [
- "validationType" => "extended"
+ 'validationType' => 'extended',
];
// Perform phone number validation.
- $response = $this->api->phone()->setOptions($options)->validate($query);
+ $response = self::$api->phone()->setOptions($options)->validate($query);
$result = $response->getResult();
// Assertions.
- $this->assertInstanceOf(Response::class, $response);
- $this->assertEquals(200, $response->getStatus());
- $this->assertFalse($result->isValid);
- $this->assertEquals("invalidWithCorrection", $result->proposal);
- $this->assertNotEmpty($response->getResultCorrected());
+ self::assertInstanceOf(Response::class, $response);
+ self::assertEquals(200, $response->getStatus());
+ self::assertFalse($result->isValid);
+ self::assertEquals('invalidWithCorrection', $result->proposal);
+ self::assertNotEmpty($response->getResultCorrected());
}
/**
* Test phone number validation with custom ID.
*/
- public function testWithCustomId()
+ public function testWithCustomId(): void
{
// Custom ID to identify the request.
$customRequestID = 'orderPhoneValidation';
// Phone number with prefix that will be sent to the API for validation.
$query = [
- "numberWithPrefix" => "+420607123456"
+ 'numberWithPrefix' => '+420607123456',
];
// Perform phone number validation.
- $response = $this->api->phone()
+ $response = self::$api->phone()
->setCustomId($customRequestID)
->validate($query);
$request = $response->getRequest();
// Assertions.
- $this->assertInstanceOf(Response::class, $response);
- $this->assertEquals(200, $response->getStatus());
- $this->assertNotEmpty($request->customId);
+ self::assertInstanceOf(Response::class, $response);
+ self::assertEquals(200, $response->getStatus());
+ self::assertNotEmpty($request->customId);
}
/**
* Test phone number validation with client information.
*/
- public function testWithClient()
+ public function testWithClient(): void
{
// Phone number with prefix that will be sent to the API for validation.
$query = [
- "numberWithPrefix" => "+420607123456"
+ 'numberWithPrefix' => '+420607123456',
];
// Perform phone number validation with client information.
- $response = $this->api->phone()
- ->setClientCountry("CZ")
- ->setClientIP("127.0.0.1")
+ $response = self::$api->phone()
+ ->setClientCountry('CZ')
+ ->setClientIP('127.0.0.1')
->setClientLocation(50.073658, 14.418540)
->validate($query);
$result = $response->getResult();
// Assertions.
- $this->assertInstanceOf(Response::class, $response);
- $this->assertEquals(200, $response->getStatus());
- $this->assertTrue($result->isValid);
+ self::assertInstanceOf(Response::class, $response);
+ self::assertEquals(200, $response->getStatus());
+ self::assertTrue($result->isValid);
}
/**
* Settings should not persist between calls.
*/
- public function testInstanceSettings()
+ public function testInstanceSettings(): void
{
// Name that will be sent to the API for validation.
$query = [
- "numberWithPrefix" => "+420607123456"
+ 'numberWithPrefix' => '+420607123456',
];
// Perform name validation with client information.
- $response = $this->api->phone()
+ $response = self::$api->phone()
->includeRequestDetails()
->validate($query);
$result = $response->getRequest();
- $this->assertObjectHasProperty('query', $result);
+ self::assertObjectHasProperty('query', $result);
- $response = $this->api->phone()
+ $response = self::$api->phone()
->validate($query);
$result = $response->getRequest();
- $this->assertObjectNotHasProperty('query', $result);
+ self::assertObjectNotHasProperty('query', $result);
}
}