-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7a7324f
Showing
16 changed files
with
544 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.{yml,yaml}] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/.github export-ignore | ||
/tests export-ignore | ||
.editorconfig export-ignore | ||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
.php-cs-fixer.dist.php export-ignore | ||
phpstan.neon export-ignore | ||
phpunit.xml.dist export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
name: Continuous Integration | ||
on: push | ||
|
||
jobs: | ||
code-quality: | ||
name: Run code quality checks on PHP 8.1 | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
dependency-version: [ '', '--prefer-lowest' ] | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.1' | ||
|
||
- name: Install dependencies | ||
run: composer update ${{ matrix.dependency-version }} --no-ansi --no-interaction --no-scripts --no-suggest --prefer-dist | ||
|
||
- name: Run PHPStan | ||
run: vendor/bin/phpstan analyze --error-format=github | ||
|
||
- name: Run PHP CS Fixer | ||
run: vendor/bin/php-cs-fixer fix --allow-risky=yes --dry-run --diff | ||
|
||
test: | ||
runs-on: ${{ matrix.os }} | ||
needs: code-quality | ||
timeout-minutes: 5 | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: [ubuntu-latest, windows-latest] | ||
php: [8.1, 8.2, 8.3] | ||
laravel: [10.*, 11.*] | ||
stability: [prefer-lowest, prefer-stable] | ||
include: | ||
- laravel: 10.* | ||
testbench: 8.* | ||
carbon: ^2.63 | ||
- laravel: 11.* | ||
testbench: 9.* | ||
carbon: ^2.63 | ||
exclude: | ||
- laravel: 11.* | ||
php: 8.1 | ||
|
||
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo | ||
coverage: none | ||
|
||
- name: Setup problem matchers | ||
run: | | ||
echo "::add-matcher::${{ runner.tool_cache }}/php.json" | ||
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" | ||
- name: Install dependencies | ||
run: | | ||
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:^2.64.1" --no-interaction --no-update | ||
composer update --${{ matrix.stability }} --prefer-dist --no-interaction | ||
- name: Execute tests | ||
run: vendor/bin/phpunit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/composer.lock | ||
/vendor | ||
.phpunit.result.cache | ||
.php-cs-fixer.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
$header = <<<'EOF' | ||
This file is part of Optimole Laravel Package. | ||
(c) Optimole Team <[email protected]> | ||
For the full copyright and license information, please view the LICENSE | ||
file that was distributed with this source code. | ||
EOF; | ||
|
||
$finder = PhpCsFixer\Finder::create() | ||
->in([ | ||
__DIR__ . '/src', | ||
__DIR__ . '/tests', | ||
]) | ||
; | ||
|
||
$config = new PhpCsFixer\Config(); | ||
$config | ||
->setRiskyAllowed(true) | ||
->setRules([ | ||
'@Symfony' => true, | ||
'@Symfony:risky' => true, | ||
'align_multiline_comment' => true, | ||
'array_syntax' => ['syntax' => 'short'], | ||
'blank_line_before_statement' => true, | ||
'combine_consecutive_issets' => true, | ||
'combine_consecutive_unsets' => true, | ||
'declare_strict_types' => true, | ||
// one should use PHPUnit methods to set up expected exception instead of annotations | ||
'general_phpdoc_annotation_remove' => ['annotations' => ['expectedException', 'expectedExceptionMessage', 'expectedExceptionMessageRegExp']], | ||
'explicit_string_variable' => true, | ||
'header_comment' => ['header' => $header], | ||
'heredoc_to_nowdoc' => true, | ||
'list_syntax' => ['syntax' => 'long'], | ||
'method_chaining_indentation' => false, | ||
'native_function_invocation' => false, | ||
'native_constant_invocation' => false, | ||
'no_extra_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']], | ||
'no_null_property_initialization' => true, | ||
'echo_tag_syntax' => ['format' => 'long'], | ||
'no_superfluous_phpdoc_tags' => ['allow_mixed' => false], | ||
'no_unneeded_curly_braces' => true, | ||
'no_unneeded_final_method' => true, | ||
'no_unreachable_default_argument_value' => true, | ||
'no_useless_else' => true, | ||
'no_useless_return' => true, | ||
'ordered_class_elements' => [ | ||
'order' => [ | ||
'use_trait', | ||
'constant_public', | ||
'constant_protected', | ||
'constant_private', | ||
'property_public', | ||
'property_protected', | ||
'property_private', | ||
'construct', | ||
'destruct', | ||
'magic', | ||
'phpunit', | ||
'method_public_static', | ||
'method_protected_static', | ||
'method_private_static', | ||
'method_public', | ||
'method_public_abstract', | ||
'method_protected', | ||
'method_protected_abstract', | ||
'method_private', | ||
], | ||
'sort_algorithm' => 'alpha' | ||
], | ||
'ordered_imports' => true, | ||
'php_unit_construct' => true, | ||
'php_unit_method_casing' => ['case' => 'camel_case'], | ||
'php_unit_dedicate_assert' => true, | ||
'phpdoc_order' => true, | ||
'phpdoc_types_order' => ['null_adjustment' => 'always_last'], | ||
'semicolon_after_instruction' => true, | ||
'single_line_comment_style' => true, | ||
'yoda_style' => true, | ||
]) | ||
->setFinder($finder) | ||
; | ||
|
||
return $config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
phpunit.xml.distCopyright (c) Optimole Team | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
of the Software, and to permit persons to whom the Software is furnished to do | ||
so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"name": "codeinwp/optimole-laravel", | ||
"description": "Integrate Optimole cloud-based image optimization service with your Laravel application", | ||
"homepage": "https://optimole.com", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Optimole Team", | ||
"email": "[email protected]", | ||
"homepage": "https://optimole.com" | ||
} | ||
], | ||
"support": { | ||
"issues": "https://github.com/Codeinwp/codeinwp/optimole-laravel/issues", | ||
"source": "https://github.com/Codeinwp/optimole-laravel" | ||
}, | ||
"require": { | ||
"illuminate/support": "^9.0|^10.0|^11.0", | ||
"codeinwp/optimole-sdk": "^1.0" | ||
}, | ||
"require-dev": { | ||
"friendsofphp/php-cs-fixer": "^3.0", | ||
"laravel/framework": "^10.0|^11.0", | ||
"orchestra/testbench": "^8.0|^9.0", | ||
"phpstan/phpstan": "^1.0" | ||
}, | ||
"config": { | ||
"optimize-autoloader": true, | ||
"preferred-install": "dist", | ||
"sort-packages": true | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Optimole\\Laravel\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Optimole\\Laravel\\Tests\\": "tests" | ||
} | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Optimole\\Laravel\\ServiceProvider" | ||
], | ||
"aliases": { | ||
"Optimole": "Optimole\\Laravel\\Facade" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
/** | ||
* Optimole Laravel configuration file. | ||
*/ | ||
return [ | ||
'key' => env('OPTIMOLE_KEY'), | ||
|
||
'base_domain' => env('OPTIMOLE_BASE_DOMAIN', 'i.optimole.com'), | ||
|
||
'cache_buster' => env('OPTIMOLE_CACHE_BUSTER', ''), | ||
|
||
'override_asset_helper' => env('OPTIMOLE_OVERRIDE_ASSET_HELPER', true), | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
parameters: | ||
level: 5 | ||
paths: | ||
- src/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="vendor/autoload.php" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
verbose="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false"> | ||
<php> | ||
<server name="OPTIMOLE_KEY" value="optimole_key"/> | ||
</php> | ||
<testsuites> | ||
<testsuite name="integration"> | ||
<directory suffix="Test.php">./tests/Integration</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of Optimole Laravel Package. | ||
* | ||
* (c) Optimole Team <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Optimole\Laravel; | ||
|
||
use Illuminate\Support\Facades\Facade as LaravelFacade; | ||
use Optimole\Sdk\Offload\Manager; | ||
use Optimole\Sdk\Optimole; | ||
use Optimole\Sdk\Resource\Asset; | ||
use Optimole\Sdk\Resource\Image; | ||
|
||
/** | ||
* @method static Asset asset(string $assetUrl, string $cacheBuster = '') | ||
* @method static Image image(string $imageUrl, string $cacheBuster = '') | ||
* @method static Manager offload() | ||
*/ | ||
class Facade extends LaravelFacade | ||
{ | ||
/** | ||
* Get the registered name of the component. | ||
* | ||
* @return string | ||
*/ | ||
protected static function getFacadeAccessor() | ||
{ | ||
return Optimole::class; | ||
} | ||
} |
Oops, something went wrong.