Skip to content

Commit

Permalink
Apply fixes from StyleCI (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
warrickbayman authored Nov 3, 2021
1 parent 77280d9 commit 94ce0b0
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/Contracts/DeadboltServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
interface DeadboltServiceInterface
{
/**
* @param array $config
* @param array $config
*/
public function __construct(array $config);

/**
* A user.
*
* @param Model $model
* @param Model $model
* @return User
*/
public function user(Model $model): User;
Expand All @@ -35,7 +35,7 @@ public function users(...$users): UserCollection;
/**
* Set permissions the driver.
*
* @param DriverInterface $driver
* @param DriverInterface $driver
* @return DeadboltServiceInterface
*/
public function driver(DriverInterface $driver): DeadboltServiceInterface;
Expand Down
12 changes: 10 additions & 2 deletions src/Contracts/UserInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ public function __construct(Model $user, array $permissions, array $config);
/**
* Give the specified permissions.
*
* @param mixed ...$names
* @param mixed ...$names
* @return UserInterface
*
* @throws JsonException|NoSuchPermissionException
*/
public function give(...$names): UserInterface;
Expand All @@ -26,6 +27,7 @@ public function give(...$names): UserInterface;
* Make a super user.
*
* @return UserInterface
*
* @throws JsonException|NoSuchPermissionException
*/
public function super(): UserInterface;
Expand All @@ -35,6 +37,7 @@ public function super(): UserInterface;
*
* @param mixed ...$names
* @return UserInterface
*
* @throws JsonException
*/
public function revoke(...$names): UserInterface;
Expand All @@ -49,7 +52,7 @@ public function revokeAll(): UserInterface;
/**
* Sync permissions with the names provided.
*
* @param mixed ...$names
* @param mixed ...$names
* @return UserInterface
*/
public function sync(...$names): UserInterface;
Expand All @@ -66,6 +69,7 @@ public function save(): UserInterface;
*
* @param string $permission
* @return bool
*
* @throws JsonException
*/
public function has(string $permission): bool;
Expand All @@ -75,6 +79,7 @@ public function has(string $permission): bool;
*
* @param mixed ...$permissions
* @return bool
*
* @throws JsonException
*/
public function hasAll(...$permissions): bool;
Expand All @@ -84,6 +89,7 @@ public function hasAll(...$permissions): bool;
*
* @param mixed ...$permissions
* @return bool
*
* @throws JsonException
*/
public function hasAny(...$permissions): bool;
Expand All @@ -93,6 +99,7 @@ public function hasAny(...$permissions): bool;
*
* @param mixed ...$permissions
* @return bool
*
* @throws JsonException
*/
public function hasNone(...$permissions): bool;
Expand All @@ -101,6 +108,7 @@ public function hasNone(...$permissions): bool;
* Get an array of permissions assigned to the user.
*
* @return array
*
* @throws JsonException
*/
public function all(): array;
Expand Down
6 changes: 3 additions & 3 deletions src/DeadboltService.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DeadboltService implements DeadboltServiceInterface
protected $driver;

/**
* @param array $config
* @param array $config
*/
public function __construct(array $config)
{
Expand All @@ -41,7 +41,7 @@ public function __construct(array $config)
/**
* A user.
*
* @param Model $model
* @param Model $model
* @return User
*/
public function user(Model $model): User
Expand All @@ -65,7 +65,7 @@ public function users(...$users): UserCollection
/**
* Set permissions the driver.
*
* @param DriverInterface $driver
* @param DriverInterface $driver
* @return DeadboltServiceInterface
*/
public function driver(DriverInterface $driver): DeadboltServiceInterface
Expand Down
6 changes: 3 additions & 3 deletions src/Drivers/ArrayDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ArrayDriver implements DriverInterface
protected $config;

/**
* @param array $config
* @param array $config
*/
public function __construct(array $config)
{
Expand All @@ -37,7 +37,7 @@ public function permissions(): array
/**
* Get the names of the permissions without descriptions.
*
* @param array $permissions
* @param array $permissions
* @return array
*/
protected function getPermissionNames(array $permissions): array
Expand All @@ -54,7 +54,7 @@ protected function getPermissionNames(array $permissions): array
/**
* Return the permission names with the descriptions.
*
* @param array $permissions
* @param array $permissions
* @return array
*/
protected function getDescriptions(array $permissions): array
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/NoSuchPermissionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class NoSuchPermissionException extends \Exception
{
/**
* @param string $permission
* @param string $permission
*/
public function __construct(string $permission)
{
Expand Down
26 changes: 18 additions & 8 deletions src/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class User implements UserInterface
protected $permissions;

/**
* @param Model $user
* @param array $permissions
* @param array $config
* @param Model $user
* @param array $permissions
* @param array $config
*/
public function __construct(Model $user, array $permissions, array $config)
{
Expand All @@ -40,8 +40,9 @@ public function __construct(Model $user, array $permissions, array $config)
/**
* Give the specified permissions.
*
* @param mixed ...$names
* @param mixed ...$names
* @return UserInterface
*
* @throws JsonException|NoSuchPermissionException
*/
public function give(...$names): UserInterface
Expand All @@ -60,7 +61,7 @@ public function give(...$names): UserInterface
/**
* Merge the specified permissions with the current permissions.
*
* @param array $permissions
* @param array $permissions
* @return UserInterface
*/
protected function assignPermissions(array $permissions): UserInterface
Expand All @@ -79,6 +80,7 @@ protected function permissionsAreCast(): bool
* Make a super user.
*
* @return UserInterface
*
* @throws JsonException|NoSuchPermissionException
*/
public function super(): UserInterface
Expand All @@ -91,6 +93,7 @@ public function super(): UserInterface
*
* @param mixed ...$names
* @return UserInterface
*
* @throws JsonException
*/
public function revoke(...$names): UserInterface
Expand All @@ -115,7 +118,7 @@ public function revokeAll(): UserInterface
/**
* Sync permissions with the names provided.
*
* @param mixed ...$names
* @param mixed ...$names
* @return UserInterface
*/
public function sync(...$names): UserInterface
Expand All @@ -138,8 +141,9 @@ public function save(): UserInterface
/**
* Check if an array is defined.
*
* @param string $permission
* @param string $permission
* @return bool
*
* @throws NoSuchPermissionException
*/
protected function exists(string $permission): bool
Expand All @@ -154,7 +158,7 @@ protected function exists(string $permission): bool
/**
* Check if the given name is a permission.
*
* @param string $name
* @param string $name
* @return bool
*/
protected function isPermission(string $name): bool
Expand All @@ -167,6 +171,7 @@ protected function isPermission(string $name): bool
*
* @param string $permission
* @return bool
*
* @throws JsonException
*/
public function has(string $permission): bool
Expand All @@ -178,6 +183,7 @@ public function has(string $permission): bool
* Get the permissions currently assigned to the user.
*
* @return array
*
* @throws JsonException
*/
protected function userPermissions(bool $refresh = false): array
Expand All @@ -195,6 +201,7 @@ protected function userPermissions(bool $refresh = false): array
*
* @param mixed ...$permissions
* @return bool
*
* @throws JsonException
*/
public function hasAll(...$permissions): bool
Expand All @@ -215,6 +222,7 @@ public function hasAll(...$permissions): bool
*
* @param mixed ...$permissions
* @return bool
*
* @throws JsonException
*/
public function hasAny(...$permissions): bool
Expand All @@ -235,6 +243,7 @@ public function hasAny(...$permissions): bool
*
* @param mixed ...$permissions
* @return bool
*
* @throws JsonException
*/
public function hasNone(...$permissions): bool
Expand All @@ -246,6 +255,7 @@ public function hasNone(...$permissions): bool
* Get an array of permissions assigned to the user.
*
* @return array
*
* @throws JsonException
*/
public function all(): array
Expand Down
5 changes: 3 additions & 2 deletions src/UserCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ public function save(): UserCollectionInterface

/**
* Call the.
* @param string $name
* @param mixed|null $arguments
*
* @param string $name
* @param mixed|null $arguments
* @return UserCollectionInterface
*/
protected function callOnEachUser(string $name, $arguments = null): UserCollectionInterface
Expand Down
3 changes: 1 addition & 2 deletions tests/EloquentDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ class EloquentDriver implements DriverInterface
{
public function permissions(): array
{
return Permission
::select(['name', 'description'])
return Permission::select(['name', 'description'])
->pluck('description', 'name')
->toArray();
}
Expand Down

0 comments on commit 94ce0b0

Please sign in to comment.