Matches if an array or string contains the expected value.

@param $actual
@return mixed
@throws InvalidArgumentException
543860
protected function doMatch($actual)
    {
        if ($actual instanceof Traversable) {
            return $this->matchTraversable($actual);
        }

        if (is_array($actual)) {
            return array_search($this->expected, $actual, true) !== false;
        }

        if (is_string($actual)) {
            return strpos($actual, $this->expected) !== false;
        }

        throw new InvalidArgumentException('Inclusion matcher requires a string or array');
    }
542096
public static function assertSameStrings($expected, $actual, string $message = '')
    {
        self::assertStringsIdentity($actual, $message, __FUNCTION__, new SameStringsConstraint($expected));
    }
239278
public static function typeMisMatch($expected, $actual)
    {
        return new static(
            sprintf(
                'Expected: "%s" Received: "%s"',
                $expected,
                is_object($actual) ? get_class($actual) : gettype($actual)
            )
        );
    }
444376
public static function MaybeThrowIfValueDoesNotMatchMultiTypedArray(
        bool $autoTrimStrings,
        bool $throwIfNotUnique,
        $value,
        string ...$types
    ) : array {
        if ( ! is_array($value)) {
            throw new InvalidArgumentException(
                'Argument 3 passed to ' .
                __METHOD__ .
                ' must be an array, ' .
                (is_object($value) ? get_class($value) : gettype($value)) .
                ' given!'
            );
        }

        /**
        * @var (scalar|array|object|null)[]
        */
        $value = $value;

        return static::MaybeThrowIfValueDoesNotMatchMultiTypedArrayValueArray(
            $autoTrimStrings,
            $throwIfNotUnique,
            $value,
            ...$types
        );
    }
844267
public function compareString($expected, $actual)
    {
        $expected .= "\0";
        $actual .= "\0";
        $expectedLength = StringHelper::byteLength($expected);
        $actualLength = StringHelper::byteLength($actual);
        $diff = $expectedLength - $actualLength;
        for ($i = 0; $i < $actualLength; $i++) {
            $diff |= (ord($actual[$i]) ^ ord($expected[$i % $expectedLength]));
        }
        return $diff === 0;
    }
1329499
static function isArrayEqual($expected, $actual) {

		if (Arrays::isNumeric($actual) and Arrays::isNumeric($expected)) {
			sort($expected);
			sort($actual);
		} else {
			asort($expected);
			asort($actual);
		}

		return $expected == $actual;
	}
208060
public function offsetExists($offset)
    {
        $allowed = array('commands', 'file', 'namespace', 'root', 'templates');

        if (in_array($offset, $allowed) === false) {
            $message = 'Key "' . $offset . '" does not exists!';

            throw new \InvalidArgumentException($message);
        }

        return $this->$offset !== null && $this->$offset !== '';
    }
1311444
static boolean containsMatch(String actual, String regex) {
    return Pattern.compile(regex).matcher(actual).find();
  }
298801
protected function matchInclusion($actual)
    {
        foreach ($this->expected as $key) {
            if (!array_key_exists($key, $actual)) {
                return false;
            }
        }

        return true;
    }
51612
protected function validate()
    {
        if (!in_array($this->operation, self::$allowedOperations, true)) {
            throw new InvalidArgumentException('Unsupported condition operation');
        }

        if (!is_array($this->value) && $this->isArrayOperation()) {
            throw new InvalidArgumentException('Value is not of type array');
        }

        if (is_array($this->value) && $this->isRangeOperation() && count($this->value) < 2) {
            throw new InvalidArgumentException('Wrong number of values for range');
        }
    }
110872
public static function match($actual, $expected)
    {
        if (is_string($actual)) {
            return strpos($actual, $expected) !== false;
        } elseif (is_array($actual) || $actual instanceof Traversable) {
            foreach ($actual as $key => $value) {
                if ($value === $expected) {
                    return true;
                }
            }
        }
        return false;
    }
659566
public function isValidRegex()
    {
        set_error_handler(function ($errno, $errstr) {
            throw new InvalidArgumentException($errstr, $errno);
        }, E_WARNING);

        $valid = true;

        try {
            preg_match($this->string, 'tester');
        } catch (InvalidArgumentException $e) {
            $valid = false;
        }

        restore_error_handler();

        return $valid;
    }
1334915
protected function matchDeep($actual)
    {
        $path = new ObjectPath($actual);
        $value = $path->get($this->getKey());

        if ($value === null) {
            return false;
        }

        $this->assertion->setActual($value->getPropertyValue());

        return $this->isExpected($value->getPropertyValue());
    }
348472
private static function hash_equals($expected, $actual) {

        $expected = (string) $expected;
        $actual   = (string) $actual;
        
        if(true === function_exists('hash_equals')) {
            return hash_equals($expected, $actual);
        }

        $lenExpected  = mb_strlen($expected, self :: ENCODING);
        $lenActual    = mb_strlen($actual, self :: ENCODING);
        $len          = min($lenExpected, $lenActual);
        $result       = 0;
        
        for ($i = 0; $i < $len; $i++) {
            $result |= ord($expected[$i]) ^ ord($actual[$i]);
        }

        $result |= $lenExpected ^ $lenActual;

        return ($result === 0);
    }
968004
static function isArraySame($expected, $actual) {

		if (Arrays::isNumeric($actual) and Arrays::isNumeric($expected)) {
			sort($expected);
			sort($actual);
		} else {
			asort($expected);
			asort($actual);
		}
		
		return $expected === $actual;
	}
974238
private function invalidReturnValue(string $what, string $expected, $actual) : \UnexpectedValueException
    {
        $message = 'Invalid return value from %s: expected %s, got %s.';
        $actual  = is_object($actual) ? get_class($actual) : gettype($actual);

        return new \UnexpectedValueException(sprintf($message, $what, $expected, $actual));
    }
194781
public static function match($actual, $expected)
    {
        $args = func_get_args();
        $expected = count($args) > 2 ? array_slice($args, 1) : $expected;
        $expected = (array) $expected;

        if (is_array($actual)) {
            foreach ($expected as $key) {
                if (!array_key_exists($key, $actual)) {
                    return false;
                }
            }
            return true;
        } elseif ($actual instanceof ArrayAccess) {
            foreach ($expected as $key) {
                if (!isset($actual[$key])) {
                    return false;
                }
            }
            return true;
        } elseif ($actual instanceof Traversable) {
            foreach ($expected as $key) {
                foreach ($actual as $k => $v) {
                    if ($key === $k) {
                        continue 2;
                    }
                }
                return false;
            }
            return true;
        }

        return false;
    }