Add a has method (similar to Input::has)


@example $bag->has('dada.dada');
@param $needle
@param null $default
@return bool
556403
public function has($needle, $default = null){
        return Arr::get($this->data, $needle, $default) ? true : false;
    }
1340777
public static function contains( $haystack, $needles )
    {
        foreach ( ( array ) $needles as $needle )
        {
            if ( '' !== $needle && FALSE !== strpos( $haystack, $needle ) )
            {
                return TRUE;
            }
        }

        return FALSE;
    }
829816
public static function endsWith($haystack, $needle)
    {
        $hl = strlen($haystack);
        $nl = strlen($needle);
        if(substr($haystack, $hl-$nl, $hl) == $needle)
            return true;

        return false;
    }
1328700
public function containsAny($needles): bool
    {
        $needlesBag = $this->transformToBag($needles);

        return !!array_intersect($needlesBag, $this->bag);
    }
877051
public function contains($needle, $caseSensitive = true)
    {
        $needle = $caseSensitive ? $needle : strtolower($needle);
        $string = $caseSensitive ? $this->returnValue : strtolower($this->returnValue);
        return (!(strpos($string, $needle) === false));
    }
26891
public function exists($needle, $haystack = null)
    {
        $result = true;
        if ($haystack && $result && $haystack[0] != "00")
            $result = in_array($needle, $haystack);
        return $result;
    }
742125
public static function stringBeginsWith($haystack, $needle)
    {
        if (!empty($needle) && strncmp($haystack, $needle, strlen($needle)) === 0) {
            return true;
        }

        return false;
    }
413644
public static function targetGet($needle, array $haystack, $default = null)
    {
        if ($needle === null) {
            return $haystack;
        }

        $parts  = preg_split('/(?<!\\\\)\./', $needle);

        foreach ($parts as $part) {
            $key = str_replace('\\.', '.', $part);

            if (
                is_array($haystack) === false ||
                array_key_exists($key, $haystack) === false
            ) {
                return $default;
            }

            $haystack = $haystack[$part];
        }

        return $haystack;
    }
853922
public static function contains($haystack, $needle)
    {
        // Check arguments
        if (empty($haystack) || empty($needle)) {
            return false;
        }

        // Needle is string
        if (!is_array($needle)) {
            return mb_strpos($haystack, $needle) !== false;
        }

        // Needle is array, check if haystack contains all items
        foreach ((array)$needle as $str_needle) {
            if (!empty($str_needle) && mb_strpos($haystack, $str_needle) === false) {
                return false;
            }
        }

        return true;
    }
284571
public static function array_isearch($needle, array $haystack, bool $strict=true) {
		if (! \count($haystack)) {
			return false;
		}

		// Lowercase for comparison.
		ref\mb::strtolower($needle, true);
		ref\mb::strtolower($haystack, true);

		// phpcs:disable
		return array_search($needle, $haystack, $strict);
		// phpcs:enable
	}
840096
public static function startsWith($haystack, $needles)
    {
        $needles = (array) $needles;

        foreach ($needles as $needle) {
            if ($needle && strpos($haystack, $needle) === 0) {
                return true;
            }
        }

        return false;
    }
926598
public function includes ($needle)
	{
		ensure('Argument', $needle, 'is_a_string', __CLASS__, __METHOD__);

		return false !== strpos($this->string, $needle);
	}
138235
public static function contains($haystack, $needle)
    {
        foreach ((array)$needle as $n) {
            if (strpos($haystack, $n) !== false) {
                return true;
            }
        }

        return false;
    }
1031064
public function contain($needle) {
        if (!$this->_isValid) {
            return $this;
        }
        if (mb_strpos($this->_unsafeVar, $needle, null, $this->conf['encoding']) === false) {
            $this->_isValid = false;
        }
        return $this;
    }
551642
public function endWithFunction($needle, $haystack = [])
    {
        if (in_array($needle, $haystack)) {
            return true;
        } else {
            foreach ($haystack as $item) {
                $length = strlen($needle);
                if (substr($haystack, -$length) === $needle) {
                    return true;
                }
            }
        }

        return false;
    }
477721
public function beginsWith($haystack, $needle, $modifiers = null)
    {
        $this->prepareHaystackAndNeedle($haystack, $needle, $modifiers);
        $parsedModifiers = $this->parseModifiers($modifiers);

        $pattern = '/^' . preg_quote($needle) . '/';

        return (bool)preg_match($pattern . $parsedModifiers, $haystack);
    }
1219244
public function search($needle)
    {
        $aIterator = new \RecursiveArrayIterator($this);
        $iterator = new \RecursiveIteratorIterator($aIterator);

        while ($iterator->valid()) {
            $iterator->current();

            if ($iterator->current() === $needle) {
                return $aIterator->key();
            }

            $iterator->next();
        }

        return false;
    }