403Webshell
Server IP : 192.158.238.246  /  Your IP : 216.73.216.83
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/7779/root/proc/7779/cwd/plugins/give/src/Framework/FieldsAPI/Concerns/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/7779/root/proc/7779/cwd/plugins/give/src/Framework/FieldsAPI/Concerns/HasOptions.php
<?php

namespace Give\Framework\FieldsAPI\Concerns;

use Give\Framework\FieldsAPI\Option;

trait HasOptions
{

    /** @var Option[] */
    protected $options = [];

    /**
     * Set the options
     *
     * Note that the keys of associative arrays are not supported for setting values or labels.
     * For setting labels either use `new FieldOption($value, $label)` or `[$value, $label]`.
     * In either case, the label is optional.
     *
     * @param Option|array|mixed ...$options
     *
     * @return $this
     */
    public function options(...$options)
    {
        // Reset options, since they are meant to be set immutably
        $this->options = [];

        // Loop through the options and transform them to the proper format.
        foreach ($options as $value) {
            if ($value instanceof Option) {
                // In this case, what is provided matches the proper format, so we can just append it.
                $this->options[] = $value;
            } elseif (is_array($value)) {
                // In this case, what has been provided in the value is an array with a value then a label.
                // This matches the constructor of `FieldOption`, so we can unpack it as arguments for a new instance.
                $this->options[] = new Option(...$value);
            } else {
                // In this case, we just have a value which is the bare minimum required for a `FieldOption`.
                $this->options[] = new Option($value);
            }
        }

        return $this;
    }

    /**
     * Access the options
     *
     * @return Option[]
     */
    public function getOptions()
    {
        return $this->options;
    }

    /**
     * Check whether options exist
     *
     * @since 2.15.0
     *
     * @return bool
     */
    public function hasOptions()
    {
        return (bool)count($this->options);
    }

    /**
     * Walk through the options
     *
     * @since 2.12.0
     *
     * @param callable $callback
     *
     * @return void
     */
    public function walkOptions(callable $callback)
    {
        foreach ($this->options as $option) {
            // Call the callback for each option.
            if ($callback($option) === false) {
                // Returning false breaks the loop.
                break;
            }
        }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit