Set From String

[code:]
fromString('bRWB');
fromString('bw+');
[code]

- reset object

@param string $modStr

@throws \InvalidArgumentException
@return $this
11307
function fromString($modStr)
    {
        $this->_reset();

        if (strpos($modStr, 'b') !== false) {
            $this->asBinary();
            $modStr = str_replace('b', '', $modStr); // remove binary sign
        }

        // default modes (r+):
        $modXXX = array_search(strtolower($modStr), $this->mode_available);

        // Mode XXX (RWB):
        $modXXX = ($modXXX!==false) ? $modXXX : strtoupper($modStr);
        for($i=0; $i < strlen($modXXX); $i++) {
            $c = $modXXX[$i];
            switch ($c) {
                // BASE:
                case 'R':
                    $this->openForRead();
                    break;
                case 'W':
                    $this->openForWrite();
                    break;
                // POINTER:
                case 'A':
                    $this->withPointerAtEnd();
                    break;
                case 'B':
                    $this->withPointerAtBeginning();
                    break;
                // CREATE:
                case 'C':
                    $this->createFile();
                    break;
                case 'X':
                    $this->createXFile();
                    break;
                // BIN:
                case 'T':
                    $this->doTruncate();
                    break;
                default:
                    throw new \InvalidArgumentException(sprintf(
                        'Invalid Open Mode Format For (%s) Contains Unknown Char (%s).',
                        $modStr, $c
                    ));
            }
        }

        return $this;
    }
1083562
public function setUnanchor($unanchor)
    {
        $allowedValues = $this->getUnanchorAllowableValues();
        if (!in_array($unanchor, $allowedValues)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'unanchor', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['unanchor'] = $unanchor;

        return $this;
    }
585140
public function setType($type)
    {
        if (! in_array($type, self::$types, true)) {
            throw new InvalidArgumentException(sprintf(
                '"%s" is not a valid type! Valid types: %s',
                $type,
                implode(', ', self::$types)
            ));
        }

        $this->type = $type;

        return $this;
    }
262733
public function setMode($mode) {

		if(false === is_string($mode)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($mode)), E_USER_ERROR);
		}

		$this -> mode = $mode;

		return $this;
	}
477004
public function mod($value)
    {
        $bigNumber = new self($value, 0, false);

        $newValue = bcmod($this->getValue(), $bigNumber->getValue());

        return $this->assignValue($newValue);
    }
1328922
private function _setModule()
	{
		if (preg_match('/^[a-z0-9_-]+$/', $this->_requestVars[0])) {
			$this->_module = $this->_requestVars[0];
        } else {
        	$this->_module = $this->_requestVars[0] = self::DEFAULT_MODULE;
        }

        return $this;
	}
1062497
public function setToPostfix($toPostfix)
    {
        if (!is_string($toPostfix) || empty($toPostfix)) {
            throw new InvalidArgumentException('"To postfix" argument must be string and must not be empty.');
        }

        $this->toPostfix = $toPostfix;

        return $this;
    }
460910
public function setCoreModxBrowserDefaultViewmode($value)
    {
        $this->setFieldName('modx_browser_default_viewmode');
        $this->loadObject(true);
        $this->setFieldValue($value);

        return $this;
    }
586654
public function setModname($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->modname !== $v) {
            $this->modname = $v;
            $this->modifiedColumns[MxmapTableMap::COL_MODNAME] = true;
        }

        return $this;
    }
950254
public function setCreateMode(int $createMode): self
    {
        $this->createModeOctal       = $createMode;
        $this->createModeOctalString = decoct($createMode);

        return $this;
    }
340239
protected function setMode($mode)
    {
        $mode = substr((string) $mode, 0, 2);
        if (!in_array($mode, $this->validModes, true)) {
            throw new \InvalidArgumentException("The given mode '$mode' is not valid for the requested operation");
        }
        $this->mode = $mode;

        return $this;
    }
611249
public function setKey(string $value) : Setting
    {

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

        return $this;
    }
87839
public function setMode($mode = self::MODE_WHITESPACE_ONLY)
    {
        if (!in_array($mode, $this->availableModes)) {
            throw new Exception\InvalidArgumentException(sprintf(
                'The mode "%s" is not available.',
                $mode
            ));
        }

        $this->mode = (string) $mode;

        return $this;
    }
1298924
public function setLang($str)
    {
        $str = strtolower($str);
        
        if ($str == 'ar' || $str == 'en') {
            $this->_lang = $str;
        }
        
        return $this;
    }
1168449
public static function fromString(string $propertyString): self
    {
        $propertyData = @parse_ini_string($propertyString, true);
        if (false === $propertyData) {
            throw new \InvalidArgumentException(
                    'Property string contains errors and can not be parsed: '
                    . lastErrorMessage()->value()
            );
        }

        return new static($propertyData);
    }
451985
public function setModule($module)
    {
        $this->module = is_string($module) ? $module : $this->$module;
        $this->prepareUrl();

        return $this;
    }
1205997
public static function fromString(string $string): self
    {
        try {
            $data = Uri\parse(trim($string));
        } catch (\Exception $e) {
            throw new InvalidArgumentException;
        }

        return new self(
            $data['scheme'] ? new Scheme($data['scheme']) : new NullScheme,
            new Authority(
                new UserInformation(
                    $data['user'] ? new User($data['user']) : new NullUser,
                    $data['pass'] ? new Password($data['pass']) : new NullPassword
                ),
                $data['host'] ? new Host($data['host']) : new NullHost,
                $data['port'] ? new Port((int) $data['port']) : new NullPort
            ),
            $data['path'] && !empty($data['path']) ? new Path($data['path']) : new NullPath,
            $data['query'] ? Query::fromString($data['query']) : new NullQuery,
            $data['fragment'] ? new Fragment($data['fragment']) : new NullFragment
        );
    }