-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '1.x' into integration/symfony-title
- Loading branch information
Showing
18 changed files
with
424 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Flow\ETL\Function; | ||
|
||
use function Flow\ETL\DSL\{type_int}; | ||
use function Symfony\Component\String\u; | ||
use Flow\ETL\Function\ScalarFunction\TypedScalarFunction; | ||
use Flow\ETL\PHP\Type\Type; | ||
use Flow\ETL\Row; | ||
|
||
final class IndexOf extends ScalarFunctionChain implements TypedScalarFunction | ||
{ | ||
public function __construct( | ||
private readonly ScalarFunction|string $string, | ||
private readonly ScalarFunction|string $needle, | ||
private readonly ScalarFunction|bool $ignoreCase = false, | ||
private readonly ScalarFunction|int $offset = 0, | ||
) { | ||
} | ||
|
||
public function eval(Row $row) : int|false|null | ||
{ | ||
$string = (new Parameter($this->string))->asString($row); | ||
$needle = (new Parameter($this->needle))->asString($row); | ||
$offset = (new Parameter($this->offset))->as($row, type_int()); | ||
$ignoreCase = (new Parameter($this->ignoreCase))->asBoolean($row); | ||
|
||
if ($string === null || $needle === null) { | ||
return false; | ||
} | ||
|
||
if ($ignoreCase) { | ||
return u($string)->ignoreCase()->indexOf($needle, $offset); | ||
} | ||
|
||
return u($string)->indexOf($needle, $offset); | ||
} | ||
|
||
public function returns() : Type | ||
{ | ||
return type_int(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Flow\ETL\Function; | ||
|
||
use function Flow\ETL\DSL\{type_boolean}; | ||
use function Symfony\Component\String\{b}; | ||
use Flow\ETL\Function\ScalarFunction\TypedScalarFunction; | ||
use Flow\ETL\PHP\Type\Type; | ||
use Flow\ETL\Row; | ||
|
||
final class IsUtf8 extends ScalarFunctionChain implements TypedScalarFunction | ||
{ | ||
public function __construct(private readonly ScalarFunction|string $string) | ||
{ | ||
} | ||
|
||
public function eval(Row $row) : mixed | ||
{ | ||
$string = (new Parameter($this->string))->asString($row); | ||
|
||
if ($string === null) { | ||
return null; | ||
} | ||
|
||
return b($string)->isUtf8(); | ||
} | ||
|
||
public function returns() : Type | ||
{ | ||
return type_boolean(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.