-
-
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.
- Loading branch information
1 parent
61e5669
commit cff3310
Showing
1 changed file
with
44 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,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SonsOfPHP\Component\Cookie; | ||
|
||
use SonsOfPHP\Contract\Cookie\CookieManagerInterface; | ||
use SonsOfPHP\Contract\Cookie\CookieInterface; | ||
use SonsOfPHP\Component\Cookie\Exception\CookieException; | ||
|
||
/** | ||
* @author Joshua Estes <joshua@sonsofphp.com> | ||
*/ | ||
final class CookieManager implements CookieManagerInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function get(string $name): CookieInterface | ||
{ | ||
$cookie = new Cookie($name); | ||
|
||
if ($this->has($name)) { | ||
$cookie = $cookie->withValue($_COOKIE[$name]); | ||
} | ||
|
||
return $cookie; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function has(string $name): CookieInterface | ||
{ | ||
return array_key_exists($name, $_COOKIE); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
//public function remove(string $name): CookieInterface | ||
//{ | ||
//} | ||
} |