HEX
Server: nginx/1.27.1
System: Linux in-4 5.15.0-131-generic #141-Ubuntu SMP Fri Jan 10 21:18:28 UTC 2025 x86_64
User: ilikadirect (1186)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source
Upload Files
File: /storage/v6964/2foodfactor/public_html/wp-content/plugins/site-reviews/plugin/Storage.php
<?php

namespace GeminiLabs\SiteReviews;

use GeminiLabs\SiteReviews\Helpers\Cast;

trait Storage
{
    /** @var Arguments */
    protected $storage;

    /**
     * @param mixed $value
     */
    public function append(string $property, $value, ?string $key = null): bool
    {
        $stored = $this->retrieve($property, []);
        if (!is_array($stored)) {
            return false;
        }
        if ($key) {
            $stored[$key] = $value;
        } else {
            $stored[] = $value;
        }
        $this->store($property, $stored);
        return true;
    }

    public function discard(string $property): void
    {
        unset($this->storage()->$property);
    }

    /**
     * @param mixed $fallback
     *
     * @return mixed
     */
    public function retrieve(string $property, $fallback = null)
    {
        return $this->storage()->get($property, $fallback);
    }

    /**
     * @param mixed $fallback
     *
     * @return mixed
     */
    public function retrieveAs(string $cast, string $property, $fallback = null)
    {
        return Cast::to($cast, $this->storage()->get($property, $fallback));
    }

    public function storage(): Arguments
    {
        if (!$this->storage instanceof Arguments) {
            $this->storage = new Arguments([]);
        }
        return $this->storage;
    }

    /**
     * @param mixed $value
     */
    public function store(string $property, $value): void
    {
        $this->storage()->set($property, $value);
    }
}