Skip to content

Commit

Permalink
manager
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaEstes committed Dec 4, 2023
1 parent 61e5669 commit cff3310
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/SonsOfPHP/Component/Cookie/CookieManager.php
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
//{
//}
}

0 comments on commit cff3310

Please sign in to comment.