Matches a string against current filter

Matches given string against the filter rule the specific object of this
class represents

@param string $string the string to match

@throws InvalidArgumentException if argument is no string
@return boolean
164990
public function match($string)
    {
        if (!is_string($string)) {
            throw new InvalidArgumentException('
                Invalid argument. Expected a string, received ' . gettype($string)
            );
        }

        return (bool) preg_match(
            '/' . $this->getRule() . '/ms', strtolower($string)
        );
    }
1153700
public static function isBoolean($string)
    {
        if (gettype($string) === 'string') {
            $string = self::toLowerTrim($string);
            if ($string == 'true') {
                return true;
            } elseif ($string == 'false') {
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
1276947
public function lookupFixtureReference($string) {
		if(preg_match('/^=>/', $string)) {
			list($className, $identifier) = explode('.', preg_replace('/^=>/', '', $string), 2);
			$id = $this->fixtureFactory->getId($className, $identifier);
			if(!$id) {
				throw new \InvalidArgumentException(sprintf(
					'Cannot resolve reference "%s", no matching fixture found',
					$string
				));
			}
			return $id;
		} else {
			return $string;
		}
	}
17590
public static function validateString($data, callable $filter=null) {
        if ( is_string($data) === false ) return false;
        return self::applyFilter($data, $filter);
    }
661278
public function equals($string)
    {
        $string = StdObjectWrapper::toString($string);

        // we double-cast the $string param to string, because integer is also a string, but in strcmp function integer
        // can cause unwanted mismatches if it's not strictly casted to string
        $result = strcmp((string)$string, $this->val());
        if ($result !== 0) {
            return false;
        }

        return true;
    }
51222
public static function toBool($string)
    {
        if (is_null($string)) {
            return false;
        }

        if (!is_scalar($string)) {
            throw new InvalidArgumentException("Value must be scalar");
        }

        if (!is_string($string)) {
            return (bool) $string;
        }

        return !in_array(strtolower($string), ['false', 'off', '-', 'no', 'n', '0', '']);
    }
112285
public function process($string)
    {
        preg_match_all($this->tagFilter, $string, $matches);

        if (!$matches) {
            return $string;
        }

        foreach ($matches[0] as $i => $m) {
            if (array_key_exists($matches[1][$i], $this->styles)) {
                $string = $this->replaceColors(
                    $string,
                    $matches[1][$i],
                    $matches[2][$i],
                    $this->styles[$matches[1][$i]]
                );
            } elseif (strpos($matches[1][$i], '=')) {
                // Custom format
                $string = $this->replaceColors(
                    $string,
                    $matches[1][$i],
                    $matches[2][$i],
                    ColorStyle::fromString($matches[1][$i])
                );
            }
        }

        return $string;
    }
176502
public static function fromString($string)
    {
        $matches = array();
        $valid = \preg_match(
            '#^([-,\+])?([0-9]*[\.\/]?[0-9]*)([-,\+]){1}([0-9]*[\.\/]?[0-9]*)i$#',
            \trim($string),
            $matches
        );

        if ($valid !== 1) {
            throw new \InvalidArgumentException(
                'The string representation of the complex number is invalid.'
            );
        }

        $real = $matches[2];
        $imaginary = $matches[4];

        if ($matches[1] && $matches[1] == '-') {
            $real = '-' . $real;
        }
        if ($matches[3] && $matches[3] == '-') {
            $imaginary = '-' . $imaginary;
        }
        
        return self::create(self::convertType($real), self::convertType($imaginary));
    }
1152722
public function contains($className)
    {
        if (!is_string($className)) {
            throw new InvalidArgumentException(sprintf('%s expects parameter 1 to be string, %s given', __METHOD__, (is_object($className) ? get_class($className) : gettype($className))));
        }

        $this->parseClassAttribute();

        return in_array($className, $this->classes, true);
    }
563035
private function isRegex(string $string): bool
    {
        if (preg_match('/^(.{3,}?)['.self::ALLOWED_MODIFIERS.']*$/', $string, $m)) {
            $start = substr($m[1], 0, 1);
            $end = substr($m[1], -1);

            if ($start === $end) {
                return !preg_match('/[*?[:alnum:] \\\\]/', $start);
            }

            foreach ([['{', '}'], ['(', ')'], ['[', ']'], ['<', '>']] as $delimiters) {
                if ($start === $delimiters[0] && $end === $delimiters[1]) {
                    return true;
                }
            }
        }

        return false;
    }
218191
public static function decode($string)
    {
        if (!is_string($string)) {
            throw new \InvalidArgumentException(sprintf(
                'Accept only string argument but got: "%s"',
                is_object($string) ? get_class($string) : gettype($string)
            ));
        }

        // PHP7 fix - empty string and null cause syntax error
        if (empty($string)) {
            return null;
        }

        $decoded = json_decode($string, true);
        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new \InvalidArgumentException(sprintf(
                'The malformed json given. Error %s and message %s',
                json_last_error(),
                json_last_error_msg()
            ));
        }

        return $decoded;
    }
576051
public static function parseString($string, array $values)
    {
        return preg_replace_callback('/#~((.|\r?\n)*?)~#/', function ($matches) use ($values) {
            $match = $matches[1];

            if (isset($values[$match])) {
                return $values[$match];
            }

            // Match is not set in the values, return just the match
            return $match;

        }, $string);
    }
945778
public static function machineName($string, $pattern = '/[^a-zA-Z0-9\-]/')
    {
        if (!is_string($string)) {
            throw new \InvalidArgumentException(
                'A non string argument has been given.'
            );
        }
        $string = strtr($string, ' ', '-');

        return strtolower(self::cleanString($string, $pattern));
    }
882513
public static function isValid($string)
    {
        if (is_int($string) || is_float($string)) {
            return true;
        }

        json_decode($string);

        return json_last_error() === JSON_ERROR_NONE;
    }
34852
public static function stringToBoolean($string)
    {
        $flag = filter_var($string, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);

        if ($flag) {
            return true;
        } elseif (is_null($flag)) {
            return $string;
        }

        return false;
    }
85695
public function contentEquals($string): bool
    {
        try {
            Assert::typeOf(['string', __CLASS__], $string);
        } catch (InvalidArgumentException|TypeError $t) {
            return false;
        }

        return $this->data === (string) $string;
    }
668763
public static function containsValidJSON($string)
	{
		try
		{
			$result = json_decode($string);
		}
		catch(\Exception $e)
		{}
		
		if(self::getJSONError() === NULL)
			return true;
		else
			return false;
	}