Skip to content

Commit

Permalink
new version
Browse files Browse the repository at this point in the history
  • Loading branch information
phphleb committed Nov 9, 2024
1 parent d0c8ef7 commit 8ccc71e
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 3 deletions.
2 changes: 1 addition & 1 deletion HlebBootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function __construct(?string $publicPath = null, array $config = [], ?Log

// The current version of the framework.
// Текущая версия фреймворка.
\defined('HLEB_CORE_VERSION') or \define('HLEB_CORE_VERSION', '2.0.36');
\defined('HLEB_CORE_VERSION') or \define('HLEB_CORE_VERSION', '2.0.37');

$this->logger = $logger;

Expand Down
16 changes: 16 additions & 0 deletions Reference/CookieInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,20 @@ public function delete(string $name): void;
* Удаление всех ранее установленных Cookies.
*/
public function clear(): void;

/**
* Checks the existence of a cookie with a specific name.
*
* Проверяет наличие cookie с конкретным названием.
*/
public function has(string $name): bool;

/**
* Checks a cookie with a specific name.
* If the cookie does not exist or the value is an empty string, it will return false.
*
* Проверяет cookie с конкретным названием.
* Если cookie не существует или значение пустая строка, то вернет false.
*/
public function exists(string $name): bool;
}
16 changes: 16 additions & 0 deletions Reference/CookieReference.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,20 @@ public static function rollback(): void
{
self::$performer::rollback();
}

/** @inheritDoc */
#[\Override]
public function has(string $name): bool
{
return self::$performer::get($name)->value() !== null;
}

/** @inheritDoc */
#[\Override]
public function exists(string $name): bool
{
$value = self::$performer::get($name)->value();

return $value !== '' && $value !== null;
}
}
2 changes: 1 addition & 1 deletion Reference/SessionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function has(string|int $name): bool;
* If the session does not exist or the value is null, it will return false.
*
* Проверяет сессию с конкретным названием.
* Если сессия на существует или значение равно null, то вернет false.
* Если сессия не существует или значение равно null, то вернет false.
*/
public function exists(string|int $name): bool;

Expand Down
30 changes: 30 additions & 0 deletions Static/Cookies.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,36 @@ public static function clear(): void
}
}

/**
* Checks the existence of a cookie with a specific name.
*
* Проверяет наличие cookie с конкретным названием.
*/
public function has(string $name): bool
{
if (self::$replace) {
return self::$replace->has($name);
}

return BaseContainer::instance()->get(CookieInterface::class)->has($name);
}

/**
* Checks a cookie with a specific name.
* If the cookie does not exist or the value is an empty string, it will return false.
*
* Проверяет cookie с конкретным названием.
* Если cookie не существует или значение пустая строка, то вернет false.
*/
public function exists(string $name): bool
{
if (self::$replace) {
return self::$replace->exists($name);
}

return BaseContainer::instance()->get(CookieInterface::class)->exists($name);
}

/**
* @internal
*
Expand Down
2 changes: 1 addition & 1 deletion Static/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static function has(string|int $name): bool
* If the session does not exist or the value is null, it will return false.
*
* Проверяет сессию с конкретным названием.
* Если сессия на существует или значение равно null, то вернет false.
* Если сессия не существует или значение равно null, то вернет false.
*/
public static function exists(string|int $name): bool
{
Expand Down

0 comments on commit 8ccc71e

Please sign in to comment.