Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"guzzlehttp/psr7": "^1.0 || ^2.0",
"php-http/curl-client": "^2.0",
"php-http/mock-client": "^1.0",
"phpcompatibility/php-compatibility": "dev-develop",
"phpstan/phpstan": "~2.1",
"phpunit/phpunit": "^9.5 || ^10.0",
"slevomat/coding-standard": "^8.20",
Expand Down
193 changes: 191 additions & 2 deletions composer.lock

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

9 changes: 9 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
<!-- Use PSR-12 standard -->
<rule ref="PSR12"/>

<!-- Check PHP 7.4 compatibility -->
<rule ref="PHPCompatibility">
<!-- Exclude functions that are polyfilled in src/polyfills.php -->
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.array_is_listFound"/>
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.str_containsFound"/>
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.str_starts_withFound"/>
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.str_ends_withFound"/>
</rule>

<!-- Enforce namespace best practices -->
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse" />
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash" />
Expand Down
2 changes: 1 addition & 1 deletion src/Providers/Http/DTO/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function getUri(): string
{
// If GET request with data, append as query parameters
if ($this->method === HttpMethodEnum::GET() && $this->data !== null && !empty($this->data)) {
$separator = strpos($this->uri, '?') === false ? '?' : '&';
$separator = str_contains($this->uri, '?') ? '&' : '?';
return $this->uri . $separator . http_build_query($this->data);
}

Expand Down
20 changes: 20 additions & 0 deletions src/polyfills.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,26 @@ function str_starts_with(string $haystack, string $needle): bool
}
}

if (!function_exists('str_contains')) {
/**
* Checks if a string contains a given substring.
*
* @since n.e.x.t
*
* @param string $haystack The string to search in.
* @param string $needle The substring to search for.
* @return bool True if $haystack contains $needle, false otherwise.
*/
function str_contains(string $haystack, string $needle): bool
{
if ('' === $needle) {
return true;
}

return false !== strpos($haystack, $needle);
}
}

if (!function_exists('str_ends_with')) {
/**
* Checks if a string ends with a given substring.
Expand Down