| 1 | <?php |
||
| 5 | class Format extends BaseDecorator |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * The available formatting options |
||
| 9 | * |
||
| 10 | * @var array |
||
| 11 | */ |
||
| 12 | protected $formats = []; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * An array of default formats |
||
| 16 | * |
||
| 17 | * @var array $defaults |
||
| 18 | */ |
||
| 19 | protected $defaults = [ |
||
| 20 | 'bold' => 1, |
||
| 21 | 'dim' => 2, |
||
| 22 | 'underline' => 4, |
||
| 23 | 'blink' => 5, |
||
| 24 | 'invert' => 7, |
||
| 25 | 'hidden' => 8, |
||
| 26 | ]; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Add a format into the mix |
||
| 30 | * |
||
| 31 | * @param string $key |
||
| 32 | * @param mixed $value |
||
| 33 | */ |
||
| 34 | 948 | public function add($key, $value) |
|
| 38 | |||
| 39 | /** |
||
| 40 | * Retrieve all of the available formats |
||
| 41 | * |
||
| 42 | * @return array |
||
| 43 | */ |
||
| 44 | 576 | public function all() |
|
| 48 | |||
| 49 | /** |
||
| 50 | * Get the code for the format |
||
| 51 | * |
||
| 52 | * @param string $val |
||
| 53 | * |
||
| 54 | * @return string |
||
| 55 | */ |
||
| 56 | 576 | public function get($val) |
|
| 69 | |||
| 70 | /** |
||
| 71 | * Set the current format |
||
| 72 | * |
||
| 73 | * @param string $val |
||
| 74 | * |
||
| 75 | * @return boolean |
||
| 76 | */ |
||
| 77 | 112 | public function set($val) |
|
| 89 | } |
||
| 90 |