4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Intl\DateFormatter\DateFormat
;
15 * Parser and formatter for date formats
17 * @author Igor Wiedler <igor@wiedler.ch>
19 abstract class Transformer
22 * Format a value using a configured DateTime as date/time source
25 * @param \DateTime $dateTime A DateTime object to be used to generate the formatted value
26 * @param int $length The formatted value string length
28 * @return string The formatted value
30 abstract public function format(\DateTime
$dateTime, $length);
33 * Returns a reverse matching regular expression of a string generated by format()
35 * @param int $length The length of the value to be reverse matched
37 * @return string The reverse matching regular expression
39 abstract public function getReverseMatchingRegExp($length);
42 * Extract date options from a matched value returned by the processing of the reverse matching
45 * @param string $matched The matched value
46 * @param int $length The length of the Transformer pattern string
48 * @return array An associative array
50 abstract public function extractDateOptions($matched, $length);
53 * Pad a string with zeros to the left
55 * @param string $value The string to be padded
56 * @param int $length The length to pad
58 * @return string The padded string
60 protected function padLeft($value, $length)
62 return str_pad($value, $length, '0', STR_PAD_LEFT
);