diff --git a/.github/workflows/formats.yml b/.github/workflows/formats.yml index f7d0a38..c4100ca 100644 --- a/.github/workflows/formats.yml +++ b/.github/workflows/formats.yml @@ -17,28 +17,28 @@ jobs: steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Cache dependencies - uses: actions/cache@v1 - with: - path: ~/.composer/cache/files - key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: dom, mbstring, zip - tools: prestissimo - coverage: pcov - - - name: Install Composer dependencies - run: composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist - - - name: Coding Style Checks - run: composer test:lint - - - name: Type Checks - run: composer test:types + - name: Checkout + uses: actions/checkout@v2 + + - name: Cache dependencies + uses: actions/cache@v1 + with: + path: ~/.composer/cache/files + key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, mbstring, zip + tools: prestissimo + coverage: pcov + + - name: Install Composer dependencies + run: composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist + + - name: Coding Style Checks + run: composer test:lint + + - name: Type Checks + run: composer test:types diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 410150a..94850ee 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,24 +16,24 @@ jobs: steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Cache dependencies - uses: actions/cache@v1 - with: - path: ~/.composer/cache/files - key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: dom, mbstring, zip - coverage: none - - - name: Install Composer dependencies - run: composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist - - - name: Integration Tests - run: php ./vendor/bin/pest + - name: Checkout + uses: actions/checkout@v2 + + - name: Cache dependencies + uses: actions/cache@v1 + with: + path: ~/.composer/cache/files + key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, mbstring, zip + coverage: none + + - name: Install Composer dependencies + run: composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist + + - name: Integration Tests + run: php ./vendor/bin/pest diff --git a/README.md b/README.md index 5159f1d..e886320 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This is a framework-agnostic PHP client for [Cloudflare Images](https://developers.cloudflare.com/images/cloudflare-images/) built on the amazing [Saloon v2](https://docs.saloon.dev/) 🤠 library. [![Latest Version on Packagist](https://img.shields.io/packagist/v/benbjurstrom/cloudflare-images-php.svg?style=flat-square)](https://packagist.org/packages/benbjurstrom/cloudflare-images-php) -[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/benbjurstrom/cloudflare-images-php/tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/benbjurstrom/cloudflare-images-php/actions?query=workflow%3tests+branch%3Amain) +[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/benbjurstrom/replicate-php/tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/benbjurstrom/cloudflare-images-php/actions?query=workflow%3tests+branch%3Amain) ## Table of contents - [Quick Start](https://github.com/benbjurstrom/cloudflare-images-php#-quick-start) @@ -31,7 +31,7 @@ composer require benbjurstrom/cloudflare-images-php ``` ### -Use your Cloudflare API token and Account ID to create a new api instance. +Create a new api instance. ```php use BenBjurstrom\CloudflareImages\CloudflareImages; ... @@ -43,7 +43,7 @@ $api = new CloudflareImages( ``` ### -Then use the api instance to get details about an existing image such as its file name, metadata, or available variants. +Then use it to get details about an existing image. ```php $id = '2cdc28f0-017a-49c4-9ed7-87056c83901' $data = $api->images()->get($id); @@ -51,7 +51,7 @@ $data->variants[0]; // https://imagedelivery.net/Vi7wi5KSItxGFsWRG2Us6Q/2cdc28f0 ``` ### -Or use the api to upload a new image from an image string. +Or to upload a new image from an image string. ```php $fileName = 'example.jpg'; $file = file_get_contents($fileName); diff --git a/src/Data/ImageData.php b/src/Data/ImageData.php index dffcd78..9c80ee4 100644 --- a/src/Data/ImageData.php +++ b/src/Data/ImageData.php @@ -29,7 +29,7 @@ public static function fromResponse(Response $response): self throw new Exception('Invalid response'); } - return new static( + return new self( id: $data['id'], filename: $data['filename'], uploaded: $data['uploaded'], diff --git a/src/Data/UploadUrlData.php b/src/Data/UploadUrlData.php index eaa6a2c..c679fbb 100644 --- a/src/Data/UploadUrlData.php +++ b/src/Data/UploadUrlData.php @@ -19,7 +19,7 @@ public static function fromResponse(Response $response): self throw new \Exception('Invalid response'); } - return new static( + return new self( id: $data['id'], uploadUrl: $data['uploadURL'], ); diff --git a/tests/FeatureTest.php b/tests/FeatureTest.php index 664e666..0211672 100644 --- a/tests/FeatureTest.php +++ b/tests/FeatureTest.php @@ -17,7 +17,7 @@ ->withCustomId('97ed2d63-d1e3-43ca-95dd-35192ce278c7') ->createFromUrl('https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg'); -// $signed = $api->signUrl('https://imagedelivery.net/tlMUIgxBCDMUcIu6pbnihg/058aae72-20b6-4eb5-c75c-dd0ca9e87601/public'); + // $signed = $api->signUrl('https://imagedelivery.net/tlMUIgxBCDMUcIu6pbnihg/058aae72-20b6-4eb5-c75c-dd0ca9e87601/public'); dd($data); // dd($signed);