Creates a DateTime instance for the given string if the format was not catch from the list
@param  string                   $string
@return \DateTime
@throws InvalidArgumentException
555764
public function stringToDateTime(string $string) : \DateTime
    {
        $this->logger->notice("unsupported date format, use strtotime() to build the DateTime instance : {$string}");

        if (false === strtotime($string)) {
            throw new \InvalidArgumentException('Impossible to convert date : '.$string);
        }
        $date = new \DateTime($string, $this->getFeedTimezone());
        $date->setTimezone($this->getTimezone());

        return $date;
    }
402539
public static function fromString(string $string): self
    {
        if (1 !== \preg_match('/^( *|\t+)$/', $string)) {
            throw Exception\InvalidIndentStringException::fromString($string);
        }

        return new self($string);
    }
537202
public static function createFromString($string) {

            if(mb_strpos($string, ':') !== false) {
                list($username, $password) = explode(':', $string, 2);
            }
            else {
                $username = $string;
                $password = $password;
            }

            return new self($username, $password);

        }
654971
public function decode($string)
    {
        if ($this->isSerialized($string)) {
            return $this->unserialize($string);
        }

        $result = json_decode($string, true);
        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new \InvalidArgumentException('Unable to unserialize value.');
        }

        return $result;
    }
1127408
public static function fromString($string)
    {
        return ctype_digit($string)
            ? new static((int) $string)
            : self::fromNative(new \DateTime($string));
    }
103198
public static function isTimestamp($string)
    {
        if (substr($string, 0, 5) == "/Date") {
            return true;
        }

        try {
            new DateTime('@' . $string);
        } catch (Exception $e) {
            return false;
        }
        return true;
    }
284279
public static function fromString( string $tokenString ) : Token
	{
		$rawToken = base64_decode( $tokenString, true );

		if ( $rawToken !== false )
		{
			$parts = explode( self::DELIMITER, $rawToken );

			$token        = new self();
			$token->token = $parts[0];

			if ( count( $parts ) === 2 )
			{
				$token->expiry = DateTimeImmutable::createFromFormat( self::DATE_FORMAT, $parts[1] );
			}

			return $token;
		}

		throw (new InvalidTokenString())->withTokenString( $tokenString );
	}
449474
protected function validateString(string $string)
    {
        if (strlen($string) > self::MAX_LENGTH || !filter_var($string, FILTER_VALIDATE_IP)) {
            throw InvalidArgumentException::format(
                    'Cannot construct class %s: argument must be a valid ip address, \'%s\' given',
                    get_class($this), $string
            );
        }
    }
1305867
public function parse( $string )
	{
		if( !is_string( $string ) )														//  no String given
			throw new InvalidArgumentException( 'Given argument is not a string' );		//  throw Exception

		$this->extendPossibleOptionsWithShortcuts();									//  realize Shortcuts

		$position	= 0;																//  initiate Sign Pointer
		$status		= self::STATUS_START;												//  initiate Status
		$buffer		= "";																//  initiate Argument Buffer
		$option		= "";																//  initiate Option Buffer

		while( isset( $string[$position] ) )											//  loop until End of String
		{
			$sign	= $string[$position];												//  get current Sign
			$position ++;																//  increase Sign Pointer

			switch( $status )															//  handle Sign depending on Status
			{
				case self::STATUS_START:												//  open for all Signs
					$this->onReady( $sign, $status, $buffer, $option );					//  handle Sign
					break;
				case self::STATUS_READ_OPTION_KEY:										//  open for Option Key Signs
					$this->onReadOptionKey( $sign, $status, $buffer, $option );			//  handle Sign
					break;
				case self::STATUS_READ_OPTION_VALUE:									//  open for Option Value Signs
					$this->onReadOptionValue( $sign, $status, $buffer, $option );		//  handle Sign
					break;
				case self::STATUS_READ_ARGUMENT:										//  open for Argument Signs
					$this->onReadArgument( $sign, $status, $buffer );					//  handle Sign
					break;
			}
		}
		$this->onEndOfLine( $status, $buffer, $option );								//  close open States
	}
1108838
public static function fromString($string)
	{
		$fg      = '';
		$bg      = '';
		$options = array();

		$parts = explode(';', $string);

		foreach ($parts as $part)
		{
			$subParts = explode('=', $part);

			if (\count($subParts) < 2)
			{
				continue;
			}

			switch ($subParts[0])
			{
				case 'fg':
					$fg = $subParts[1];

					break;

				case 'bg':
					$bg = $subParts[1];

					break;

				case 'options':
					$options = explode(',', $subParts[1]);

					break;

				default:
					throw new \RuntimeException('Invalid option');

					break;
			}
		}

		return new self($fg, $bg, $options);
	}
1040653
public static function fromString($string)
    {
        $okay = strlen($string) < 256;
        Assertion::true($okay, 'StreamId cannot be greater than 255 chars.', 'StreamId');
        if (!preg_match(self::VALID_PATTERN, $string, $matches)) {
            throw new InvalidArgumentException(
                sprintf(
                    'StreamId [%s] is invalid.  It must match the pattern [%s].',
                    $string,
                    self::VALID_PATTERN
                )
            );
        }

        return new self(
            $matches[1],
            isset($matches[3]) ? $matches[3] : null,
            isset($matches[5]) ? $matches[5] : null
        );
    }
1062319
public static function isFuture( $string )
	{
		$string	= Alg_Time_Converter::complementMonthDate( $string );
		$time	= strtotime( $string );
		if( $time === false )
			throw new InvalidArgumentException( 'Given Date "'.$string.'" could not been parsed.' );
		return $time > time();
	}
612672
protected function createDateFromFormat($dateString)
	{
		foreach($this->allowedDateFormats as $df) {
			if(($dt = \DateTime::createFromFormat($df, $dateString)) === false)
				continue;
			
			$lastErrors = $dt->getLastErrors();

			if($lastErrors['warning_count'] > 0 || $lastErrors['error_count'] > 0) {
				return false;
			}
			
			return $dt;
		}

		return false;
	}
1300624
private function _processDateTime($dateTime)
    {
        if (is_numeric($dateTime)) {
            $timestamp = $dateTime;
            $dateTime = new \DateTime();
            $dateTime->setTimestamp($timestamp);
        } elseif (empty($dateTime)) {
            throw new \InvalidArgumentException('Date/time is empty');
        } elseif (is_string($dateTime)) {
            $dateTime = new \DateTime($dateTime);
        }

        if (!($dateTime instanceof \DateTime)) {
            throw new \InvalidArgumentException('Incorrect date/time type');
        }
        return $dateTime;
    }
1233103
public static function createFromString($string)
    {
        $file = new SplTempFileObject(-1);

        if (null === $file->fwrite($string)) {
            throw new Exception("Cannot create file");
        }

        return new static($file);
    }
1121392
public function add($string)
    {
        $this->timestamp = $this->getTimestamp() + $this->evaluateDateString($string);

        return $this;
    }
119341
protected function execute($string)
    {
        foreach ($this->patternsAndReplacements as $patternAndReplacement) {
            $tmp = preg_replace("/".$patternAndReplacement->pattern."/s", $patternAndReplacement->replacement, $string);
            if ($tmp === null) {
                InvalidExpression::invalidRegex($patternAndReplacement->pattern, $patternAndReplacement->replacement);
            } else {
                $string = $tmp;
            }
        }
        
        return $string;
    }