Skip to content

Commit

Permalink
Merge pull request #13 from jakubenglicky/php81
Browse files Browse the repository at this point in the history
Travis to Github Actions
  • Loading branch information
jakubenglicky committed Aug 11, 2022
2 parents 40441d9 + 1a3fca6 commit bc4559a
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 46 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: CI

on:
pull_request:
types: [opened, synchronize]

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
cs:
timeout-minutes: 2
runs-on: ubuntu-latest
name: Coding standard
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'

- name: Composer Update
run: composer update

- name: CS Check
run: vendor/bin/phpcs --standard=ruleset.xml --extensions=php,phpt src/ tests/

phpstan:
timeout-minutes: 2
runs-on: ubuntu-latest
name: PHPStan lv. 7
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'

- name: Composer Update
run: composer update

- name: PHPStan lv. 7
run: vendor/bin/phpstan.phar analyse -l 7 src

unit:
timeout-minutes: 2
runs-on: ubuntu-latest
name: Unit Tests
strategy:
matrix:
version: [ 7.4, 8.0, 8.1 ]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.version }}

- name: Composer Update
run: composer update

- name: Nette Tester
run: vendor/bin/tester tests/
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],

"require": {
"php": "^7.1 || ^8.0",
"php": "^7.4 || ^8.0 || ^8.1",
"guzzlehttp/guzzle": "^6.3 || ^7.0",
"smartemailing/types": "^1.1",
"tracy/tracy": "^2.4",
Expand All @@ -23,7 +23,7 @@
"nette/tester": "^2.0",
"nette/di": "^2.4",
"squizlabs/php_codesniffer": "*",
"phpstan/phpstan": "^0.12"
"phpstan/phpstan": "^1.8"
},

"autoload": {
Expand Down
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
php:
image: php:8.1-cli
working_dir: /src
volumes:
- ./:/src

composer:
image: composer
working_dir: /src
volumes:
- ./:/src
4 changes: 1 addition & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
parameters:
autoload_directories:
- ./src/SmsManager/Diagnostics
excludes_analyse:
excludePaths:
- ./src/SmsManager/Diagnostics/Panel.php
ignoreErrors:
- '#Method jakubenglicky\\SmsManager\\Diagnostics\\Response::[A-Za-z]+\(\) should return [A-Za-z\<\>]+ but return statement is missing\.#'
Expand Down
11 changes: 7 additions & 4 deletions src/SmsManager/DI/SmsManagerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@

class SmsManagerExtension extends CompilerExtension
{
protected $defaults = [
'apiKey' => null,
];
/**
* @var array<string, mixed>
*/
protected array $defaults = [
'apiKey' => null,
];

public function loadConfiguration(): void
{
$config = $this->validateConfig($this->defaults);
$config = $this->validateConfig($this->defaults);

$builder = $this->getContainerBuilder();

Expand Down
2 changes: 1 addition & 1 deletion src/SmsManager/Diagnostics/DebugClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function send(Message $message): ?Sent
$message
);
}
return null;
return null;
}

public function getUserInfo()
Expand Down
8 changes: 4 additions & 4 deletions src/SmsManager/Diagnostics/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

class Response implements ResponseInterface
{
/** @var StreamInterface|string */
/** @var StreamInterface|string */
private $body;

/**
* @param StreamInterface|string $body
*/
/**
* @param StreamInterface|string $body
*/
public function __construct($body)
{
$this->body = $body;
Expand Down
18 changes: 9 additions & 9 deletions src/SmsManager/Http/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ final class Client implements IClient
*/
private $apiKey;

/**
* Client constructor.
* @param string $apiKey
* @throws MissingCredentialsException
*/
/**
* Client constructor.
* @param string $apiKey
* @throws MissingCredentialsException
*/
public function __construct(string $apiKey)
{
if (empty($apiKey)) {
throw new MissingCredentialsException('Please fill apiKey.');
}
if (empty($apiKey)) {
throw new MissingCredentialsException('Please fill apiKey.');
}
$this->apiKey = $apiKey;
$this->client = new GuzzleHttp\Client();
}
Expand All @@ -67,7 +67,7 @@ public function __construct(string $apiKey)
*/
public function send(Message $message)
{
try {
try {
$res = $this->client->post('https://http-api.smsmanager.cz/Send', [
'form_params' => [
'apikey' => $this->apiKey,
Expand Down
2 changes: 1 addition & 1 deletion src/SmsManager/Http/Responses/UserInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class UserInfo
/** @var string $body */
private $body;

/** @var float $credit */
/** @var string $credit */
private $credit;

/** @var string $sender */
Expand Down

0 comments on commit bc4559a

Please sign in to comment.