File tree Expand file tree Collapse file tree 1 file changed +8
-17
lines changed
Expand file tree Collapse file tree 1 file changed +8
-17
lines changed Original file line number Diff line number Diff line change 1010final class CssSelector implements Selector
1111{
1212 /** @var string */
13- private $ expression ;
13+ private $ expressionEncoded ;
1414
1515 public function __construct (string $ expression )
1616 {
17- $ this ->expression = $ expression ;
18- }
19-
20- public function expressionCount (): string
21- {
22- $ encodedExpr = \json_encode (
23- $ this ->expression ,
17+ $ this ->expressionEncoded = \json_encode (
18+ $ expression ,
2419 \JSON_UNESCAPED_SLASHES
2520 | \JSON_UNESCAPED_UNICODE
2621 | \JSON_THROW_ON_ERROR
2722 );
23+ }
2824
25+ public function expressionCount (): string
26+ {
2927 return \sprintf (
3028 'document.querySelectorAll(%s).length ' ,
31- $ encodedExpr
29+ $ this -> expressionEncoded
3230 );
3331 }
3432
3533 public function expressionFindOne (int $ position ): string
3634 {
37- $ encodedExpr = \json_encode (
38- $ this ->expression ,
39- \JSON_UNESCAPED_SLASHES
40- | \JSON_UNESCAPED_UNICODE
41- | \JSON_THROW_ON_ERROR
42- );
43-
4435 return \sprintf (
4536 'document.querySelectorAll(%s)[%d] ' ,
46- $ encodedExpr ,
37+ $ this -> expressionEncoded ,
4738 $ position - 1
4839 );
4940 }
You can’t perform that action at this time.
0 commit comments