Set options.

@param mixed $type : option type
@param mixed $value : option value
@throws \Exception

@return self
179810
public function set($type, $value) {
        switch ($type) {
            case self::CMD:
                $this->cmd = $value;
                break;
            case self::ENV:
                $this->env = $value;
                break;
            case self::CWD:
                $this->cwd = $value;
                break;
            case self::TYPE:
                if ($value == self::PIPE)
                    $this->descriptor_spec = [['pipe', 'r'], ['pipe', 'w']];
                elseif ($value == self::PTY)
                    //To execute command in pty, PHP_CAN_DO_PTS must be enabled before PHP compile.
                    //See ext/standard/proc_open.c in PHP source directory.
                    $this->descriptor_spec = [['pty'], ['pty']];
                break;
            case self::ON_MESSAGE:
                $this->onMessage = $value;
                break;
            case self::ON_CLOSE:
                $this->onClose = $value;
                break;
            default:
                throw new \Exception("Invalid option.");
        }
        return $this;
    }
1106241
public function setValue($value) : self
    {
        if (is_bool($value)) {
            $value = ($value == true) ? '1' : '0';
        }

        $this->field->addAttribute('value', !is_null($value) ? (string) $value : '');

        return $this;
    }
1025383
public function setType($type): self
    {
        if ($type instanceof Type) {
            $this->setIndex($type->getIndex()->getName());
            $type = $type->getName();
        }

        $this->_type = (string) $type;

        return $this;
    }
1337769
public function setOptions($option, $value = null) 
	{
		Argument::i()
			->test(1, 'array', 'string')
			->test(2, 'scalar', 'null');
		
		if(is_array($option)) {
			$this->options = $option;
			return $this;
		}
		
		$this->options[$option] = $value;
		return $this;
	}
65980
public function setOption(string $key, $value): void
    {
        if (array_key_exists($key, $this->options)) {
            $this->options[$key] = $value;

            return;
        }

        throw new Exception('Invalid option key "' . $key . '".', Exception::INVALID_OPTION);
    }
41420
public function setOption($option, $value = null)
    {
        if (is_array($option)) {
            $this->options += $option;
        } else {
            $this->options[$option] = $value;
        }

        return $this;
    }
297663
public function setType($type)
    {
        if ($type === null) {
            $type = self::TYPE_UNDEFINED;
        }

        $this->type = $type;

        return $this;
    }
913364
private function setExpiring($type, $subtype, $value)
    {
        if (!isset($this->expiring[$type][$subtype])) {
            throw new \InvalidArgumentException("Invalid type or parameter given.");
        }

        $this->expiring[$type][$subtype] = $value;

        return $this;
    }
1142207
protected function setValue($value)
    {
        if (! is_bool($value)) {
            throw InvalidTypeException::fromMessageAndPrototype("Value must be a boolean", static::prototype());
        }

        $this->value = $value;
    }
71482
public function setType($type = null)
    {
        $type = $this->calculateTypeValue($type);

        if (!is_int($type) || ($type < 0) || ($type > self::ALL)) {
            throw new Exception\InvalidArgumentException('Unknown type');
        }

        $this->options['type'] = $type;

        return $this;
    }
47876
protected function update($type, $field, $value)
    {
        $this->update[$field] = [$type, $value];

        return $this;
    }
37636
public function setValue($value) {
		if (is_array($value)) {
		    foreach ($value as $singleValue) {
		        if (!$this->isValueValid($singleValue)) {
		            throw new \Exception('Unexpected value type');
		        }
		    }
		} elseif (!$this->isValueValid($value)) {
		    throw new \Exception('Unexpected value type');
		}
		$this->value = $value;

		return $this;
	}
901989
public function setType(string $type):self
    {
        if (!isset($this->types[$type])) {
            Checkers::notice('Unknown response type [' . $type . ']');
        } else {
            $this->type = $type;
        }
        return $this;
    }
103194
public function setValue($value): FieldTypeInterface
    {
        $this->value = $this->transformer->transform($value);

        return $this;
    }
1048707
public function setType(string $value) : ScheduledJob
    {

        if ($this->data['type'] !== $value) {
            $this->data['type'] = $value;
            $this->setModified('type');
        }

        return $this;
    }
29810
public function setByType($type)
    {
        if (isset(self::$sourceList[$type])) {
            $this->value = self::$sourceList[$type];
        } else {
            throw new Exception("undefined index $type");
        }
    }
1373323
public function set($key, $value) {
        if (!is_string($key)) throw new IllegalTypeException('Illegal type of parameter $key: '.gettype($key));
        $this->setProperty($key, $value);
        return $this;
    }