flexible-shipping
/
src
/
WPDesk
/
FS
/
TableRate
/
FreeShipping
/
LffsNoticeTextFormatValidator.php
Tracker
2 weeks ago
Assets.php
2 weeks ago
FreeShippingNotice.php
2 weeks ago
FreeShippingNoticeData.php
2 weeks ago
FreeShippingNoticeGenerator.php
2 weeks ago
FreeShippingNoticeRenderer.php
2 weeks ago
LffsNoticeTextFormatValidator.php
2 weeks ago
NoticeTextSettings.php
2 weeks ago
ProgressBarSettings.php
2 weeks ago
Tracker.php
2 weeks ago
LffsNoticeTextFormatValidator.php
36 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class LffsNoticeTextFormatValidator |
| 4 | * |
| 5 | * @package WPDesk\FS\TableRate\FreeShipping |
| 6 | */ |
| 7 | |
| 8 | declare( strict_types=1 ); |
| 9 | |
| 10 | namespace WPDesk\FS\TableRate\FreeShipping; |
| 11 | |
| 12 | /** |
| 13 | * Validates LFFS notice text placeholder format. |
| 14 | */ |
| 15 | final class LffsNoticeTextFormatValidator { |
| 16 | |
| 17 | /** |
| 18 | * @param string $message LFFS notice text. |
| 19 | * |
| 20 | * @return bool |
| 21 | */ |
| 22 | public function is_valid( string $message ): bool { |
| 23 | if ( '' === $message ) { |
| 24 | return true; |
| 25 | } |
| 26 | |
| 27 | try { |
| 28 | sprintf( $message, '' ); |
| 29 | } catch ( \Throwable $e ) { |
| 30 | return false; |
| 31 | } |
| 32 | |
| 33 | return true; |
| 34 | } |
| 35 | } |
| 36 |