1 | <?php |
||
5 | class Formatter implements FormatInterface |
||
6 | { |
||
7 | /** |
||
8 | * A local reference to the name being formatted. |
||
9 | * @var NameInterface |
||
10 | */ |
||
11 | protected $name; |
||
12 | |||
13 | /** |
||
14 | * Create a new formatter given the specified name |
||
15 | * |
||
16 | * @param NameInterface $name The name to format. |
||
17 | */ |
||
18 | public function __construct(NameInterface $name) |
||
22 | |||
23 | /** |
||
24 | * A static method for quickly formatting a name. |
||
25 | * |
||
26 | * @param NameInterface $name The name to format. |
||
27 | * @param string $format The format to follow. |
||
28 | * |
||
29 | * @return string |
||
30 | */ |
||
31 | public static function nameLike(NameInterface $name, $format) |
||
37 | |||
38 | /** |
||
39 | * {@inheritdoc} |
||
40 | */ |
||
41 | public function like($format) |
||
56 | |||
57 | /** |
||
58 | * Format and return the given string chunk otherise |
||
59 | * return null. |
||
60 | * |
||
61 | * @param string $string The string to format. |
||
62 | * |
||
63 | * @return string | null |
||
64 | */ |
||
65 | protected function format($string) |
||
95 | |||
96 | /** |
||
97 | * Tries to process the given string chunk, otherwise |
||
98 | * returns null. |
||
99 | * |
||
100 | * @param string $needle The format specifier. |
||
101 | * @param string $name The name part. |
||
102 | * @param string $string The full string to format. |
||
103 | * |
||
104 | * @return string | null |
||
105 | */ |
||
106 | protected function processString($needle, $name, $string) |
||
114 | } |
||
115 |