-
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.
Merge pull request #2 from ARCANEDEV/update-github_actions
Using GitHub Actions for testing
- Loading branch information
Showing
20 changed files
with
229 additions
and
74 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
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,46 @@ | ||
name: run-tests | ||
|
||
on: [push] | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: true | ||
matrix: | ||
php: [7.2, 7.3, 7.4] | ||
laravel: [6.*] | ||
dependency-version: [prefer-lowest, prefer-stable] | ||
|
||
name: PHP ${{ matrix.php }} - ${{ matrix.dependency-version }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v1 | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/.composer/cache/files | ||
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v1 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv | ||
coverage: xdebug | ||
|
||
- name: Install dependencies | ||
run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest | ||
|
||
- name: Execute tests | ||
run: | | ||
mkdir -p build/logs | ||
vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover | ||
- name: Scrutinizer CI | ||
run: | | ||
wget https://scrutinizer-ci.com/ocular.phar | ||
php ocular.phar code-coverage:upload --format=php-clover coverage.clover |
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
This file was deleted.
Oops, something went wrong.
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
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
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 |
---|---|---|
|
@@ -4,18 +4,17 @@ | |
|
||
namespace Arcanedev\LaravelPolicies; | ||
|
||
use Illuminate\Contracts\Support\{Arrayable, Jsonable}; | ||
use Arcanedev\LaravelPolicies\Contracts\Ability as AbilityContract; | ||
use Closure; | ||
use Illuminate\Support\Arr; | ||
use JsonSerializable; | ||
|
||
/** | ||
* Class Ability | ||
* | ||
* @package Arcanedev\LaravelPolicies | ||
* @author ARCANEDEV <[email protected]> | ||
*/ | ||
class Ability implements Arrayable, JsonSerializable, Jsonable | ||
class Ability implements AbilityContract | ||
{ | ||
/* ----------------------------------------------------------------- | ||
| Properties | ||
|
@@ -93,7 +92,7 @@ public function setKey(string $key): self | |
/** | ||
* Get the ability's method. | ||
* | ||
* @return string|Closure | ||
* @return \Closure|string | ||
*/ | ||
public function method() | ||
{ | ||
|
@@ -115,7 +114,7 @@ public function callback(Closure $callback): self | |
/** | ||
* Set the ability's method. | ||
* | ||
* @param string|\Closure $method | ||
* @param \Closure|string $method | ||
* | ||
* @return self | ||
*/ | ||
|
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,113 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Arcanedev\LaravelPolicies\Contracts; | ||
|
||
use Illuminate\Contracts\Support\{Arrayable, Jsonable}; | ||
use Closure; | ||
use JsonSerializable; | ||
|
||
/** | ||
* Interface Ability | ||
* | ||
* @package Arcanedev\LaravelPolicies\Contracts | ||
* @author ARCANEDEV <[email protected]> | ||
*/ | ||
interface Ability extends Arrayable, JsonSerializable, Jsonable | ||
{ | ||
/* ----------------------------------------------------------------- | ||
| Getters & Setters | ||
| ----------------------------------------------------------------- | ||
*/ | ||
|
||
/** | ||
* Get the ability's key. | ||
* | ||
* @return string | ||
*/ | ||
public function key(): string; | ||
|
||
/** | ||
* Set the ability's key. | ||
* | ||
* @param string $key | ||
* | ||
* @return $this | ||
*/ | ||
public function setKey(string $key); | ||
|
||
/** | ||
* Get the ability's method. | ||
* | ||
* @return \Closure|string | ||
*/ | ||
public function method(); | ||
|
||
/** | ||
* Set the callback as method. | ||
* | ||
* @param \Closure $callback | ||
* | ||
* @return $this | ||
*/ | ||
public function callback(Closure $callback); | ||
|
||
/** | ||
* Set the ability's method. | ||
* | ||
* @param \Closure|string $method | ||
* | ||
* @return $this | ||
*/ | ||
public function setMethod($method); | ||
|
||
/** | ||
* Get the ability's meta. | ||
* | ||
* @return array | ||
*/ | ||
public function metas(): array; | ||
|
||
/** | ||
* Set the ability's meta. | ||
* | ||
* @param array $metas | ||
* @param bool $keepMetas | ||
* | ||
* @return $this | ||
*/ | ||
public function setMetas(array $metas, bool $keepMetas = true); | ||
|
||
/** | ||
* Get a meta. | ||
* | ||
* @param string $key | ||
* @param mixed|null $default | ||
* | ||
* @return mixed | ||
*/ | ||
public function meta(string $key, $default = null); | ||
|
||
/** | ||
* Set a meta. | ||
* | ||
* @param string $key | ||
* @param mixed $value | ||
* | ||
* @return $this | ||
*/ | ||
public function setMeta(string $key, $value); | ||
|
||
/* ----------------------------------------------------------------- | ||
| Check Methods | ||
| ----------------------------------------------------------------- | ||
*/ | ||
|
||
/** | ||
* Check if the ability is a callback method. | ||
* | ||
* @return bool | ||
*/ | ||
public function isClosure(): bool; | ||
} |
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
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
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
Oops, something went wrong.