diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml new file mode 100644 index 0000000..051dfdc --- /dev/null +++ b/.github/workflows/psalm.yml @@ -0,0 +1,33 @@ +name: Psalm + +on: + push: + paths: + - '**.php' + - 'psalm.xml.dist' + +jobs: + psalm: + name: psalm + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + extensions: json + coverage: none + + - name: Cache composer dependencies + uses: actions/cache@v2 + with: + path: vendor + key: composer-${{ hashFiles('composer.lock') }} + + - name: Run composer install + run: composer install -n --prefer-dist + + - name: Run psalm + run: ./vendor/bin/psalm --output-format=github diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..c3278d5 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,38 @@ +name: run-tests + +on: + push: + pull_request: + schedule: + - cron: "0 0 * * *" + +jobs: + test: + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository + timeout-minutes: 15 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + php: ["7.4", "8.0", "8.1"] + dependency-version: ["prefer-lowest", "prefer-stable"] + os: ["ubuntu-latest", "windows-latest"] + + name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: json + coverage: none + + - name: Install dependencies + run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest + + - name: Execute tests + run: vendor/bin/phpunit diff --git a/.gitignore b/.gitignore index d769eb5..dddbc6a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ vendor -.phpunit.result.cache +.phpunit.cache composer.lock diff --git a/composer.json b/composer.json index 11b3173..7670e2e 100644 --- a/composer.json +++ b/composer.json @@ -4,11 +4,12 @@ "type": "library", "keywords": [], "require": { - "php": ">=7.4", + "php": "^7.4 || ^8.0", "ext-json": "*", "psr/http-factory": "^1.0", "psr/http-client": "^1.0", - "guzzlehttp/guzzle": "^6.0 || ^7.0" + "guzzlehttp/guzzle": "^6.5.2 || ^7.0", + "guzzlehttp/psr7": "^1.7.0" }, "require-dev": { "http-interop/http-factory-guzzle": "^1.0", diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..8d3e365 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,24 @@ + + + + + tests + + + + + + src + + + diff --git a/psalm.xml b/psalm.xml.dist similarity index 100% rename from psalm.xml rename to psalm.xml.dist diff --git a/src/Offers/OffersListDto.php b/src/Offers/OffersListDto.php index 6271462..0879229 100644 --- a/src/Offers/OffersListDto.php +++ b/src/Offers/OffersListDto.php @@ -36,7 +36,7 @@ class OffersListDto extends BaseOfferDto protected int $noticePercentOvercap; protected float $cr; protected float $epc; - protected ?string $notes; + protected string $notes; protected string $allowedIp; protected string $disallowedIp; protected string $hashPassword; @@ -86,7 +86,7 @@ public function __construct(array $attributes) $this->noticePercentOvercap = $attributes['notice_percent_overcap']; $this->cr = $attributes['cr']; $this->epc = $attributes['epc']; - $this->notes = $attributes['notes']; + $this->notes = $attributes['notes'] ?? ''; $this->allowedIp = $attributes['allowed_ip']; $this->disallowedIp = $attributes['disallowed_ip']; $this->hashPassword = $attributes['hash_password'];