2021-02-28 12:53:28 +00:00
|
|
|
<?php
|
|
|
|
|
2021-05-09 20:15:43 +00:00
|
|
|
declare (strict_types=1);
|
2022-06-06 17:12:56 +00:00
|
|
|
namespace Rector\Php80\ValueObjectFactory;
|
2021-02-28 12:53:28 +00:00
|
|
|
|
2022-06-06 17:12:56 +00:00
|
|
|
use PhpParser\Node\Expr\FuncCall;
|
|
|
|
use Rector\Php80\ValueObject\StrStartsWith;
|
2021-02-28 12:53:28 +00:00
|
|
|
final class StrStartsWithFactory
|
|
|
|
{
|
2022-06-07 08:22:29 +00:00
|
|
|
public function createFromFuncCall(FuncCall $funcCall, bool $isPositive) : ?StrStartsWith
|
2021-09-27 15:43:15 +00:00
|
|
|
{
|
2023-05-13 17:20:02 +00:00
|
|
|
if (\count($funcCall->getArgs()) < 2) {
|
2021-09-27 15:43:15 +00:00
|
|
|
return null;
|
|
|
|
}
|
2023-05-13 17:20:02 +00:00
|
|
|
$haystack = $funcCall->getArgs()[0]->value;
|
|
|
|
$needle = $funcCall->getArgs()[1]->value;
|
2022-06-07 08:22:29 +00:00
|
|
|
return new StrStartsWith($funcCall, $haystack, $needle, $isPositive);
|
2021-02-28 12:53:28 +00:00
|
|
|
}
|
|
|
|
}
|