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\Rules\Grammar\JavaScript\Methods;
use nicoSWD\Rules\Core\CallableFunction;
use nicoSWD\Rules\Tokens\BaseToken;
use nicoSWD\Rules\Tokens\TokenInteger;
final class IndexOf extends CallableFunction
{
* @param BaseToken $needle
* @return BaseToken
public function call($needle = null): BaseToken
if (!$needle) {
$value = -1;
} else {
$value = strpos($this->token->getValue(), $needle->getValue());
if ($value === false) {
}
return new TokenInteger(
$value,
$this->token->getOffset(),
$this->token->getStack()
);