-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve: Eliminate abstract requirements from NullAuthenticatable (#2)
* Refactor: Use mock() instead of spy() * Improve: Eliminate abstract requirements from NullAuthenticatable
- Loading branch information
Showing
9 changed files
with
186 additions
and
122 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,31 @@ | ||
<?php | ||
|
||
namespace Mpyw\NullAuth\Concerns; | ||
|
||
/** | ||
* Trait HasEloquentIdentifier | ||
* | ||
* @mixin \Illuminate\Database\Eloquent\Model | ||
*/ | ||
trait HasEloquentIdentifier | ||
{ | ||
/** | ||
* Get the name of the unique identifier for the user. | ||
* | ||
* @return string | ||
*/ | ||
public function getAuthIdentifierName() | ||
{ | ||
return $this->getKeyName(); | ||
} | ||
|
||
/** | ||
* Get the unique identifier for the user. | ||
* | ||
* @return mixed | ||
*/ | ||
public function getAuthIdentifier() | ||
{ | ||
return $this->{$this->getKeyName()}; | ||
} | ||
} |
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 @@ | ||
<?php | ||
|
||
namespace Mpyw\NullAuth\Concerns; | ||
|
||
trait RequiresIdentifier | ||
{ | ||
/** | ||
* Get the name of the unique identifier for the user. | ||
* | ||
* @return string | ||
*/ | ||
abstract public function getAuthIdentifierName(); | ||
|
||
/** | ||
* Get the unique identifier for the user. | ||
* | ||
* @return mixed | ||
*/ | ||
abstract public function getAuthIdentifier(); | ||
} |
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,48 @@ | ||
<?php | ||
|
||
namespace Mpyw\NullAuth; | ||
|
||
trait GenericNullAuthenticatable | ||
{ | ||
use Concerns\RequiresIdentifier; | ||
|
||
/** | ||
* Get the password for the user. | ||
* | ||
* @return string | ||
*/ | ||
public function getAuthPassword() | ||
{ | ||
return ''; | ||
} | ||
|
||
/** | ||
* Get the token value for the "remember me" session. | ||
* | ||
* @return string | ||
*/ | ||
public function getRememberToken() | ||
{ | ||
return ''; | ||
} | ||
|
||
/** | ||
* Set the token value for the "remember me" session. | ||
* | ||
* @param string $value | ||
* @return void | ||
*/ | ||
public function setRememberToken($value) | ||
{ | ||
} | ||
|
||
/** | ||
* Get the column name for the "remember me" token. | ||
* | ||
* @return string | ||
*/ | ||
public function getRememberTokenName() | ||
{ | ||
return ''; | ||
} | ||
} |
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,50 @@ | ||
<?php | ||
|
||
namespace Mpyw\NullAuth; | ||
|
||
use LogicException; | ||
|
||
trait GenericStrictNullAuthenticatable | ||
{ | ||
use Concerns\RequiresIdentifier; | ||
|
||
/** | ||
* Get the password for the user. | ||
* | ||
* @return string | ||
*/ | ||
public function getAuthPassword() | ||
{ | ||
throw new LogicException('Not implemented'); | ||
} | ||
|
||
/** | ||
* Get the token value for the "remember me" session. | ||
* | ||
* @return string | ||
*/ | ||
public function getRememberToken() | ||
{ | ||
throw new LogicException('Not implemented'); | ||
} | ||
|
||
/** | ||
* Set the token value for the "remember me" session. | ||
* | ||
* @param string $value | ||
*/ | ||
public function setRememberToken($value) | ||
{ | ||
throw new LogicException('Not implemented'); | ||
} | ||
|
||
/** | ||
* Get the column name for the "remember me" token. | ||
* | ||
* @return string | ||
*/ | ||
public function getRememberTokenName() | ||
{ | ||
throw new LogicException('Not implemented'); | ||
} | ||
} |
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
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