-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganize methods, refactor code, general cleaning.
- Loading branch information
1 parent
87ae38c
commit 7b48bfc
Showing
6 changed files
with
276 additions
and
238 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,78 @@ | ||
<?php | ||
|
||
namespace Illuminate\Auth; | ||
|
||
use Illuminate\Support\Str; | ||
|
||
class Recaller | ||
{ | ||
/** | ||
* The "recaller" / "remember me" cookie string. | ||
* | ||
* @var string | ||
*/ | ||
protected $recaller; | ||
|
||
/** | ||
* Create a new recaller instance. | ||
* | ||
* @param string $recaller | ||
* @return void | ||
*/ | ||
public function __construct($recaller) | ||
{ | ||
$this->recaller = $recaller; | ||
} | ||
|
||
/** | ||
* Get the user ID from the recaller. | ||
* | ||
* @return string | ||
*/ | ||
public function id() | ||
{ | ||
return explode('|', $this->recaller, 2)[0]; | ||
} | ||
|
||
/** | ||
* Get the "remember token" token from the recaller. | ||
* | ||
* @return string | ||
*/ | ||
public function token() | ||
{ | ||
return explode('|', $this->recaller, 2)[1]; | ||
} | ||
|
||
/** | ||
* Determine if the recaller is valid. | ||
* | ||
* @return bool | ||
*/ | ||
public function valid() | ||
{ | ||
return $this->properString() && $this->hasBothSegments(); | ||
} | ||
|
||
/** | ||
* Determine if the recaller is an invalid string. | ||
* | ||
* @return bool | ||
*/ | ||
protected function properString() | ||
{ | ||
return is_string($this->recaller) && Str::contains($this->recaller, '|'); | ||
} | ||
|
||
/** | ||
* Determine if the recaller has both segments. | ||
* | ||
* @return bool | ||
*/ | ||
protected function hasBothSegments() | ||
{ | ||
$segments = explode('|', $this->recaller); | ||
|
||
return count($segments) == 2 && trim($segments[0]) !== '' && trim($segments[1]) !== ''; | ||
} | ||
} |
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.