| 1: | <?php declare(strict_types=1); |
| 2: | |
| 3: | namespace Salient\Console\Format; |
| 4: | |
| 5: | use Salient\Contract\Console\Format\MessageAttributesInterface; |
| 6: | use Salient\Contract\Console\Format\MessageFormatInterface; |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | final class NullMessageFormat implements MessageFormatInterface |
| 12: | { |
| 13: | private NullFormat $Format; |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | public function __construct() |
| 19: | { |
| 20: | $this->Format = new NullFormat(); |
| 21: | } |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | public function apply( |
| 27: | string $msg1, |
| 28: | ?string $msg2, |
| 29: | string $prefix, |
| 30: | MessageAttributesInterface $attributes |
| 31: | ): string { |
| 32: | return ( |
| 33: | $prefix !== '' |
| 34: | ? $this->Format->apply($prefix, $attributes->withPrefix()) |
| 35: | : '' |
| 36: | ) . ( |
| 37: | $msg1 !== '' |
| 38: | ? $this->Format->apply($msg1, $attributes->withMsg1()) |
| 39: | : '' |
| 40: | ) . ( |
| 41: | $msg2 !== null && $msg2 !== '' |
| 42: | ? $this->Format->apply($msg2, $attributes->withMsg2()) |
| 43: | : '' |
| 44: | ); |
| 45: | } |
| 46: | } |
| 47: | |