Source of file Parameter.php

Size: 1,421 Bytes - Last Modified: 2018-11-03T09:50:48-04:00

G:/AdobeConnectClient/src/Parameter.php

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
<?php

namespace AdobeConnectClient;

use AdobeConnectClient\Helpers\StringCaseTransform as SCT;
use AdobeConnectClient\Helpers\ValueTransform as VT;

/**
 * A generic Parameter class to extra parameters.
 */
class Parameter implements ArrayableInterface
{
    /**
     * @var array
     */
    protected $parameters = [];

    /**
     * Returns a new Parameter instance
     *
     * @return Parameter
     */
    public static function instance()
    {
        return new static;
    }

    /**
     * Add a parameter
     *
     * @param string $parameter
     * @param mixed $value
     * @return Parameter Fluent Interface
     */
    public function set($parameter, $value)
    {
        $this->parameters[SCT::toHyphen($parameter)] = VT::toString($value);
        return $this;
    }

    /**
     * Remove a parameter
     *
     * @param string $parameter
     * @return Parameter Fluent Interface
     */
    public function remove($parameter)
    {
        $parameter = SCT::toHyphen($parameter);

        if (isset($this->parameters[$parameter])) {
            unset($this->parameters[$parameter]);
        }
        return $this;
    }

    /**
     * Retrieves all not null attributes in an associative array
     *
     * The keys in hash style: Ex: is-member
     * The values as string
     *
     * @return string[]
     */
    public function toArray()
    {
        return $this->parameters;
    }
}