aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Transformer.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Transformer.php')
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Transformer.php64
1 files changed, 64 insertions, 0 deletions
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Transformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Transformer.php
new file mode 100644
index 00000000..0e67f8ae
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Transformer.php
@@ -0,0 +1,64 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\DateFormatter\DateFormat;
13
14/**
15 * Parser and formatter for date formats
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19abstract class Transformer
20{
21 /**
22 * Format a value using a configured DateTime as date/time source
23 *
24 *
25 * @param \DateTime $dateTime A DateTime object to be used to generate the formatted value
26 * @param int $length The formatted value string length
27 *
28 * @return string The formatted value
29 */
30 abstract public function format(\DateTime $dateTime, $length);
31
32 /**
33 * Returns a reverse matching regular expression of a string generated by format()
34 *
35 * @param int $length The length of the value to be reverse matched
36 *
37 * @return string The reverse matching regular expression
38 */
39 abstract public function getReverseMatchingRegExp($length);
40
41 /**
42 * Extract date options from a matched value returned by the processing of the reverse matching
43 * regular expression
44 *
45 * @param string $matched The matched value
46 * @param int $length The length of the Transformer pattern string
47 *
48 * @return array An associative array
49 */
50 abstract public function extractDateOptions($matched, $length);
51
52 /**
53 * Pad a string with zeros to the left
54 *
55 * @param string $value The string to be padded
56 * @param int $length The length to pad
57 *
58 * @return string The padded string
59 */
60 protected function padLeft($value, $length)
61 {
62 return str_pad($value, $length, '0', STR_PAD_LEFT);
63 }
64}