| Server IP : 185.252.147.100 / Your IP : 216.73.217.33 Web Server : nginx/1.27.3 System : Linux mitrofanov.ru 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64 User : mitr ( 1000) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /www/html/tour.mitrofanov.ru/public/wp-content/plugins/site-reviews/plugin/ |
Upload File : |
<?php
namespace GeminiLabs\SiteReviews;
use GeminiLabs\SiteReviews\Helpers\Arr;
use GeminiLabs\SiteReviews\Helpers\Cast;
use GeminiLabs\SiteReviews\Helpers\Str;
use GeminiLabs\SiteReviews\Modules\Sanitizer;
class Arguments extends \ArrayObject
{
/**
* @param mixed $args
*/
public function __construct($args = [])
{
if ($args instanceof Arguments) {
$args = $args->toArray();
} else {
$args = Arr::consolidate($args);
}
parent::__construct($args, \ArrayObject::STD_PROP_LIST | \ArrayObject::ARRAY_AS_PROPS);
}
public function __toString(): string
{
return serialize($this->toArray());
}
/**
* @param mixed $key
*/
public function array($key, array $fallback = []): array
{
return Arr::consolidate($this->get($key, $fallback));
}
/**
* @param mixed $key
*
* @return mixed
*/
public function cast($key, string $cast, $fallback = null)
{
return Cast::to($cast, $this->get($key, $fallback));
}
public function exists(string $key): bool
{
return $this->offsetExists($key);
}
/**
* @param mixed $key
* @param mixed $fallback
*
* @return mixed
*/
public function get($key, $fallback = null)
{
$value = Arr::get($this->getArrayCopy(), $key, null);
if (is_null($fallback)) {
return $value;
}
return Helper::ifEmpty($value, $fallback);
}
public function isEmpty(): bool
{
return empty($this->getArrayCopy());
}
/**
* @return self
*/
public function merge(array $data = [])
{
$storage = wp_parse_args($data, $this->getArrayCopy());
$this->exchangeArray($storage);
return $this;
}
/**
* @param mixed $key
*
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($key)
{
return $this->get($key);
}
/**
* @param mixed $key
*/
#[\ReturnTypeWillChange]
public function offsetUnset($key): void
{
$storage = $this->getArrayCopy();
unset($storage[$key]);
$this->exchangeArray($storage);
}
/**
* @return self
*/
public function replace(array $data = [])
{
$this->exchangeArray($data);
return $this;
}
/**
* @param mixed $key
*
* @return mixed
*/
public function sanitize($key, string $sanitizer)
{
$sanitizers = ['key' => $sanitizer];
$values = ['key' => $this->get($key)];
$values = glsr(Sanitizer::class, compact('values', 'sanitizers'))->run();
return Arr::get($values, 'key');
}
/**
* @param mixed $value
*/
public function set(string $path, $value): void
{
$storage = Arr::set($this->getArrayCopy(), $path, $value);
$this->exchangeArray($storage);
}
public function toArray(array $excludedKeys = []): array
{
$array = Cast::toArrayDeep($this->getArrayCopy());
$excluded = array_fill_keys($excludedKeys, null);
return array_diff_key($array, $excluded);
}
}