for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types=1);
/**
* @license http://opensource.org/licenses/mit-license.php MIT
* @link https://github.com/nicoSWD
* @author Nicolas Oelgart <[email protected]>
*/
namespace nicoSWD\Rule\Grammar\JavaScript\Methods;
use nicoSWD\Rule\Grammar\CallableFunction;
use nicoSWD\Rule\TokenStream\Token\BaseToken;
use nicoSWD\Rule\TokenStream\Token\TokenInteger;
final class IndexOf extends CallableFunction
{
public function call(?BaseToken ...$parameters): BaseToken
$needle = $this->parseParameter($parameters, numParam: 0);
if (!$needle) {
$value = -1;
} else {
$value = strpos($this->token->getValue(), $needle->getValue());
token
nicoSWD\Rule\Grammar\JavaScript\Methods\IndexOf
if ($value === false) {
}
return new TokenInteger($value);