Get a compatible data.

@param $haystack
@param $title
@param $mode
@param $script

@return mixed|null
352797
public function getCompatibleData($haystack, $title, $mode, $script)
    {
        // List of choices order by importance.
        $choices = $this->getChoicesByPriority($title, $mode, $script);

        foreach ($choices as $choice) {
            $data = AssociativeArray::getFromKey($haystack, $choice);

            if (!is_null($data)) {
                return $data;
            }
        }

        return null;
    }
477109
public static function ireplace($needle, $replacement, ?string $haystack): ?string
    {
        if ($haystack === null) {
            return null;
        }

        return str_ireplace($needle, $replacement, $haystack);
    }
811711
protected function tagSearch($needle, array $haystack)
    {
        foreach ($haystack as $actual) {
            if (0 === strcasecmp($needle, $actual)) {
                return $actual;
            }
        }

        return null;
    }
1161222
protected function endsWith($haystack, $needle)
    {
        $length = \mb_strlen($needle);

        return $length === 0 || (\mb_substr($haystack, -$length) === $needle);
    }
1239455
public function in_multiarray($needle, $haystack)
    {
        foreach ($haystack as $value) {
            if (is_array($value)) {
                if ($this->in_multiarray($needle, $value)) {
                    return true;
                }
            } else {
                if ($value == $needle) {
                    return true;
                }
            }
        }
        return false;
    }
1065592
private function arrayObjectContains(DependencyNode $needle, ArrayObject $haystack)
    {
        foreach ($haystack as $node) {
            if ($node === $needle) {
                return true;
            }
        }

        return false;
    }
1258817
public static String getVarFromQueryString(String varName, String haystack) {
		if (haystack == null || haystack.length() == 0) {
			return null;
		}

		String modifiedHaystack = haystack;

		if (modifiedHaystack.charAt(0) == '?') {
			modifiedHaystack = modifiedHaystack.substring(1);
		}
		String[] vars = modifiedHaystack.split("&");

		for (String var : vars) {
			String[] tuple = var.split("=");
			if (tuple.length == 2 && tuple[0].equals(varName)) {
				return tuple[1];
			}
		}
		return null;
	}
697528
public static function startsWith($haystack, $needle, $case_sensitive = true)
    {
        $status = false;

        $compare_func = $case_sensitive ? 'mb_strpos' : 'mb_stripos';

        foreach ((array)$needle as $each_needle) {
            $status = $each_needle === '' || $compare_func($haystack, $each_needle) === 0;
            if ($status) {
                break;
            }
        }

        return $status;
    }
1312080
public static function has(string $needle, string $haystack): bool
    {
        return $needle === '' || strpos($haystack, $needle) !== false;
    }
1051470
public static function indexOf(string $haystack, string $needle, int $nth = 1): ?int
    {
        $pos = static::pos($haystack, $needle, $nth);

        return $pos === null
            ? null
            : \mb_strlen(\substr($haystack, 0, $pos));
    }
786224
public function whereTitle($title, callable $callback = null)
    {
        $item = $this->findBy('title', $title);

        if (is_callable($callback)) {
            return call_user_func($callback, $item);
        }

        return $item;
    }
1261342
function get(scriptModule, agent, msg, cb) {
    const filename = msg.filename;
    if (!filename) {
        cb('empty filename');
        return;
    }

    fs.readFile(path.join(scriptModule.root, filename), 'utf-8', (err, data) => {
        if (err) {
            logger.error(`fail to read script file:${filename}, ${err.stack}`);
            cb(`fail to read script with name:${filename}`);
        }

        cb(null, data);
    });
}
31724
public static function hasBeginning(string $needle, string $haystack): bool
    {
        return $needle === '' || strpos($haystack, $needle) === 0;
    }
610316
protected function enableDisablePlugins($title, $mode, $script, Map $map)
    {
        $pluginsToEnable = [];
        $pluginsToProcess = $this->plugins;

        do {
            $lastEnabledPluginCount = count($pluginsToEnable);
            $pluginsToProcessNew = [];

            foreach ($pluginsToProcess as $pluginId => $plugin) {
                if ($this->isPluginCompatible($plugin, $pluginsToEnable, $title, $mode, $script, $map)) {
                    $pluginsToEnable[$pluginId] = $plugin;
                } else {
                    $pluginsToProcessNew[$pluginId] = $plugin;
                }
            }

            $pluginsToProcess = $pluginsToProcessNew;
        } while ($lastEnabledPluginCount != count($pluginsToEnable) && !empty($pluginsToProcess));

        /* Enable plugins so that the data providers are propelry connected */
        $enableNotify = [];
        foreach ($pluginsToEnable as $pluginId => $plugin) {
            $enableNotify[$pluginId] = $this->enablePlugin($plugin, $title, $mode, $script, $map);
        }

        $disableNotify = [];
        foreach ($pluginsToProcess as $pluginId => $plugin) {
            $disableNotify[$pluginId] = $this->disablePlugin($plugin);
        }

        /* Once all is connected send status update */
        foreach ($enableNotify as $pluginId => $plugin) {
            if (!is_null($plugin)) {
                $this->console->getConsoleOutput()->writeln("<info>Enabling plugin : $pluginId</info>");
                if ($plugin instanceof StatusAwarePluginInterface) {
                    $plugin->setStatus(true);
                }
            }
        }
        foreach ($disableNotify as $pluginId => $plugin) {
            if (!is_null($plugin)) {
                $this->console->writeln("<info>Disabling plugin : $pluginId</info>");
                if ($plugin instanceof StatusAwarePluginInterface) {
                    $plugin->setStatus(false);
                }
            }
        }
    }
1071991
function (needle, haystack, strict) {

            var found = false;

            strict = !!strict;

            $this.each(haystack, function (key) {
                /* jshint -W116 */
                if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
                    found = true;
                    return false;
                }
                /* jshint +W116 */
            });

            return found;
        }
26891
public function exists($needle, $haystack = null)
    {
        $result = true;
        if ($haystack && $result && $haystack[0] != "00")
            $result = in_array($needle, $haystack);
        return $result;
    }
28891
public function findIn($haystack) : array
    {
        $matches = [];
        call_user_func_array(
            $this->_method,
            [
                sprintf("/%s/%s", $this->_expr, $this->_flags),
                $haystack,
                &$matches,
                $this->_pregMatchFlags ?: null,
            ]
        );

        if (!isset($matches[1]) && isset($matches[0]) && is_array($matches[0])) {
            return $matches[0];
        }

        return $matches;
    }