aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/symfony/intl
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/intl')
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/.gitignore3
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/CONTRIBUTING.md91
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Collator/Collator.php295
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/AmPmTransformer.php46
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfWeekTransformer.php59
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfYearTransformer.php46
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayTransformer.php46
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php356
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1200Transformer.php62
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1201Transformer.php62
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2400Transformer.php61
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2401Transformer.php64
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/HourTransformer.php30
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/MinuteTransformer.php48
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/MonthTransformer.php143
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/QuarterTransformer.php64
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/SecondTransformer.php48
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php99
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Transformer.php64
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/YearTransformer.php50
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php631
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Exception/BadMethodCallException.php21
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Exception/ExceptionInterface.php21
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Exception/InvalidArgumentException.php21
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Exception/MethodArgumentNotImplementedException.php32
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Exception/MethodArgumentValueNotImplementedException.php41
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Exception/MethodNotImplementedException.php28
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Exception/NotImplementedException.php32
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Exception/OutOfBoundsException.php21
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Exception/RuntimeException.php21
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Globals/IntlGlobals.php137
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Intl.php211
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/LICENSE19
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Locale/Locale.php317
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php891
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/README.md25
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/AbstractBundle.php71
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Compiler/BundleCompiler.php71
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Compiler/BundleCompilerInterface.php29
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/CurrencyBundle.php94
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/CurrencyBundleInterface.php74
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php115
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/LanguageBundleInterface.php64
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/LocaleBundle.php52
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/LocaleBundleInterface.php41
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/AbstractBundleReader.php42
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/BinaryBundleReader.php51
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/BufferedBundleReader.php62
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/BundleReaderInterface.php40
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/PhpBundleReader.php61
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReader.php113
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReaderInterface.php50
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/RegionBundle.php52
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/RegionBundleInterface.php41
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/ResourceBundleInterface.php27
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/BundleTransformer.php96
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContext.php97
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContextInterface.php56
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/CurrencyBundleTransformationRule.php94
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LanguageBundleTransformationRule.php71
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LocaleBundleTransformationRule.php251
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/RegionBundleTransformationRule.php70
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/TransformationRuleInterface.php70
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContext.php80
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContextInterface.php46
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Util/ArrayAccessibleResourceBundle.php79
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Util/RecursiveArrayAccess.php33
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Util/RingBuffer.php88
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Writer/BundleWriterInterface.php29
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Writer/PhpBundleWriter.php50
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Writer/TextBundleWriter.php202
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/autoload.php18
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/common.php69
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/copy-stubs-to-component.php63
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/create-stubs.php112
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/icu-version.php18
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/icu.ini9
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/test-compat.php56
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/update-icu-component.php212
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/util/test-compat-helper.php23
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Resources/stubs/Collator.php21
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Resources/stubs/IntlDateFormatter.php21
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Resources/stubs/Locale.php21
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Resources/stubs/NumberFormatter.php21
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Resources/stubs/functions.php80
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/AbstractCollatorTest.php62
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/CollatorTest.php109
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/Verification/CollatorTest.php37
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php932
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php220
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/DateFormatter/Verification/IntlDateFormatterTest.php64
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/Globals/AbstractIntlGlobalsTest.php41
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/Globals/IntlGlobalsTest.php22
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/Globals/Verification/IntlGlobalsTest.php36
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/Locale/AbstractLocaleTest.php29
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/Locale/LocaleTest.php159
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/Locale/Verification/LocaleTest.php38
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php707
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php239
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/NumberFormatter/Verification/NumberFormatterTest.php54
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/AbstractBundleTest.php55
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/CurrencyBundleTest.php98
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/LanguageBundleTest.php197
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/LocaleBundleTest.php64
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/AbstractBundleReaderTest.php64
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/BinaryBundleReaderTest.php58
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/NotAFile/en.php/.gitkeep0
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.php14
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.resbin0 -> 84 bytes
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.txt3
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/PhpBundleReaderTest.php63
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/StructuredBundleReaderTest.php223
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/RegionBundleTest.php63
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Util/RingBufferTest.php101
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.php23
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.resbin0 -> 316 bytes
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.txt23
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/PhpBundleWriterTest.php62
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/TextBundleWriterTest.php67
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/IcuVersionTest.php111
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/VersionTest.php87
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Util/IcuVersion.php105
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Util/IntlTestHelper.php128
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Util/SvnCommit.php66
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Util/SvnRepository.php141
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Util/Version.php96
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/composer.json48
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/phpunit.xml.dist29
128 files changed, 12250 insertions, 0 deletions
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/.gitignore b/vendor/symfony/intl/Symfony/Component/Intl/.gitignore
new file mode 100644
index 00000000..c49a5d8d
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/.gitignore
@@ -0,0 +1,3 @@
1vendor/
2composer.lock
3phpunit.xml
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/CONTRIBUTING.md b/vendor/symfony/intl/Symfony/Component/Intl/CONTRIBUTING.md
new file mode 100644
index 00000000..315c28ab
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/CONTRIBUTING.md
@@ -0,0 +1,91 @@
1Contributing to the Intl component
2==================================
3
4A very good way of contributing to the Intl component is by updating the
5included data for the ICU version you have installed on your system.
6
7Preparation
8-----------
9
10To prepare, you need to install the development dependencies of the component.
11
12 $ cd /path/to/Symfony/Component/Intl
13 $ composer.phar install --dev
14
15Determining your ICU version
16---------------------------
17
18The ICU version installed in your PHP environment can be found by running
19icu-version.php:
20
21 $ php Resources/bin/icu-version.php
22
23Updating the ICU data
24---------------------
25
26To update the data files, run the update-icu-component.php script:
27
28 $ php Resources/bin/update-icu-component.php
29
30The script needs the binaries "svn" and "make" to be available on your system.
31It will download the latest version of the ICU sources for the ICU version
32installed in your PHP environment. The script will then compile the "genrb"
33binary and use it to compile the ICU data files to binaries. The binaries are
34copied to the Resources/ directory of the Icu component found in the
35vendor/symfony/icu/ directory.
36
37Updating the stub data
38----------------------
39
40In the previous step you updated the Icu component for the ICU version
41installed on your system. If you are using the latest ICU version, you should
42also create the stub data files which will be used by people who don't have
43the intl extension installed.
44
45To update the stub files, run the update-stubs.php script:
46
47 $ php Resources/bin/update-stubs.php
48
49The script will fail if you don't have the latest ICU version. If you want to
50upgrade the ICU version, adjust the return value of the
51`Intl::getIcuStubVersion()` before you run the script.
52
53The script creates copies of the binary resource bundles in the Icu component
54and stores them in the Resources/ directory of the Intl component. The copies
55are made for the locale "en" only and are stored in .php files, so that they
56can be read even if the intl extension is not available.
57
58Creating a pull request
59-----------------------
60
61You need to create up to two pull requests:
62
63* If you updated the Icu component, you need to push that change and create a
64 pull request in the `symfony/Icu` repository. Make sure to submit the pull
65 request to the correct master branch. If you updated the ICU data for version
66 4.8, your pull request goes to branch `48-master`, for version 49 to
67 `49-master` and so on.
68
69* If you updated the stub files of the Intl component, you need to push that
70 change and create a pull request in the `symfony/symfony` repository. The
71 pull request should be based on the `master` branch.
72
73Combining .res files to a .dat-package
74--------------------------------------
75
76The individual *.res files can be combined into a single .dat-file.
77Unfortunately, PHP's `ResourceBundle` class is currently not able to handle
78.dat-files.
79
80Once it is, the following steps have to be followed to build the .dat-file:
81
821. Package the resource bundles into a single file
83
84 $ find . -name *.res | sed -e "s/\.\///g" > packagelist.txt
85 $ pkgdata -p region -T build -d . packagelist.txt
86
872. Clean up
88
89 $ rm -rf build packagelist.txt
90
913. You can now move region.dat to replace the version bundled with Symfony2.
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Collator/Collator.php b/vendor/symfony/intl/Symfony/Component/Intl/Collator/Collator.php
new file mode 100644
index 00000000..8c0ffc33
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Collator/Collator.php
@@ -0,0 +1,295 @@
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\Collator;
13
14use Symfony\Component\Intl\Exception\MethodNotImplementedException;
15use Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException;
16use Symfony\Component\Intl\Globals\IntlGlobals;
17use Symfony\Component\Intl\Locale\Locale;
18
19/**
20 * Replacement for PHP's native {@link \Collator} class.
21 *
22 * The only methods currently supported in this class are:
23 *
24 * - {@link \__construct}
25 * - {@link create}
26 * - {@link asort}
27 * - {@link getErrorCode}
28 * - {@link getErrorMessage}
29 * - {@link getLocale}
30 *
31 * @author Igor Wiedler <igor@wiedler.ch>
32 * @author Bernhard Schussek <bschussek@gmail.com>
33 */
34class Collator
35{
36 /* Attribute constants */
37 const FRENCH_COLLATION = 0;
38 const ALTERNATE_HANDLING = 1;
39 const CASE_FIRST = 2;
40 const CASE_LEVEL = 3;
41 const NORMALIZATION_MODE = 4;
42 const STRENGTH = 5;
43 const HIRAGANA_QUATERNARY_MODE = 6;
44 const NUMERIC_COLLATION = 7;
45
46 /* Attribute constants values */
47 const DEFAULT_VALUE = -1;
48
49 const PRIMARY = 0;
50 const SECONDARY = 1;
51 const TERTIARY = 2;
52 const DEFAULT_STRENGTH = 2;
53 const QUATERNARY = 3;
54 const IDENTICAL = 15;
55
56 const OFF = 16;
57 const ON = 17;
58
59 const SHIFTED = 20;
60 const NON_IGNORABLE = 21;
61
62 const LOWER_FIRST = 24;
63 const UPPER_FIRST = 25;
64
65 /* Sorting options */
66 const SORT_REGULAR = 0;
67 const SORT_NUMERIC = 2;
68 const SORT_STRING = 1;
69
70 /**
71 * Constructor
72 *
73 * @param string $locale The locale code. The only currently supported locale is "en".
74 *
75 * @throws MethodArgumentValueNotImplementedException When $locale different than "en" is passed
76 */
77 public function __construct($locale)
78 {
79 if ('en' != $locale) {
80 throw new MethodArgumentValueNotImplementedException(__METHOD__, 'locale', $locale, 'Only the locale "en" is supported');
81 }
82 }
83
84 /**
85 * Static constructor
86 *
87 * @param string $locale The locale code. The only currently supported locale is "en".
88 *
89 * @return Collator
90 *
91 * @throws MethodArgumentValueNotImplementedException When $locale different than "en" is passed
92 */
93 public static function create($locale)
94 {
95 return new self($locale);
96 }
97
98 /**
99 * Sort array maintaining index association
100 *
101 * @param array &$array Input array
102 * @param integer $sortFlag Flags for sorting, can be one of the following:
103 * Collator::SORT_REGULAR - compare items normally (don't change types)
104 * Collator::SORT_NUMERIC - compare items numerically
105 * Collator::SORT_STRING - compare items as strings
106 *
107 * @return Boolean True on success or false on failure
108 */
109 public function asort(&$array, $sortFlag = self::SORT_REGULAR)
110 {
111 $intlToPlainFlagMap = array(
112 self::SORT_REGULAR => \SORT_REGULAR,
113 self::SORT_NUMERIC => \SORT_NUMERIC,
114 self::SORT_STRING => \SORT_STRING,
115 );
116
117 $plainSortFlag = isset($intlToPlainFlagMap[$sortFlag]) ? $intlToPlainFlagMap[$sortFlag] : self::SORT_REGULAR;
118
119 return asort($array, $plainSortFlag);
120 }
121
122 /**
123 * Not supported. Compare two Unicode strings
124 *
125 * @param string $str1 The first string to compare
126 * @param string $str2 The second string to compare
127 *
128 * @return Boolean|int Return the comparison result or false on failure:
129 * 1 if $str1 is greater than $str2
130 * 0 if $str1 is equal than $str2
131 * -1 if $str1 is less than $str2
132 *
133 * @see http://www.php.net/manual/en/collator.compare.php
134 *
135 * @throws MethodNotImplementedException
136 */
137 public function compare($str1, $str2)
138 {
139 throw new MethodNotImplementedException(__METHOD__);
140 }
141
142 /**
143 * Not supported. Get a value of an integer collator attribute
144 *
145 * @param int $attr An attribute specifier, one of the attribute constants
146 *
147 * @return Boolean|int The attribute value on success or false on error
148 *
149 * @see http://www.php.net/manual/en/collator.getattribute.php
150 *
151 * @throws MethodNotImplementedException
152 */
153 public function getAttribute($attr)
154 {
155 throw new MethodNotImplementedException(__METHOD__);
156 }
157
158 /**
159 * Returns collator's last error code. Always returns the U_ZERO_ERROR class constant value
160 *
161 * @return int The error code from last collator call
162 */
163 public function getErrorCode()
164 {
165 return IntlGlobals::U_ZERO_ERROR;
166 }
167
168 /**
169 * Returns collator's last error message. Always returns the U_ZERO_ERROR_MESSAGE class constant value
170 *
171 * @return string The error message from last collator call
172 */
173 public function getErrorMessage()
174 {
175 return 'U_ZERO_ERROR';
176 }
177
178 /**
179 * Returns the collator's locale
180 *
181 * @param int $type Not supported. The locale name type to return (Locale::VALID_LOCALE or Locale::ACTUAL_LOCALE)
182 *
183 * @return string The locale used to create the collator. Currently always
184 * returns "en".
185 */
186 public function getLocale($type = Locale::ACTUAL_LOCALE)
187 {
188 return 'en';
189 }
190
191 /**
192 * Not supported. Get sorting key for a string
193 *
194 * @param string $string The string to produce the key from
195 *
196 * @return string The collation key for $string
197 *
198 * @see http://www.php.net/manual/en/collator.getsortkey.php
199 *
200 * @throws MethodNotImplementedException
201 */
202 public function getSortKey($string)
203 {
204 throw new MethodNotImplementedException(__METHOD__);
205 }
206
207 /**
208 * Not supported. Get current collator's strength
209 *
210 * @return Boolean|int The current collator's strength or false on failure
211 *
212 * @see http://www.php.net/manual/en/collator.getstrength.php
213 *
214 * @throws MethodNotImplementedException
215 */
216 public function getStrength()
217 {
218 throw new MethodNotImplementedException(__METHOD__);
219 }
220
221 /**
222 * Not supported. Set a collator's attribute
223 *
224 * @param int $attr An attribute specifier, one of the attribute constants
225 * @param int $val The attribute value, one of the attribute value constants
226 *
227 * @return Boolean True on success or false on failure
228 *
229 * @see http://www.php.net/manual/en/collator.setattribute.php
230 *
231 * @throws MethodNotImplementedException
232 */
233 public function setAttribute($attr, $val)
234 {
235 throw new MethodNotImplementedException(__METHOD__);
236 }
237
238 /**
239 * Not supported. Set the collator's strength
240 *
241 * @param int $strength Strength to set, possible values:
242 * Collator::PRIMARY
243 * Collator::SECONDARY
244 * Collator::TERTIARY
245 * Collator::QUATERNARY
246 * Collator::IDENTICAL
247 * Collator::DEFAULT
248 *
249 * @return Boolean True on success or false on failure
250 *
251 * @see http://www.php.net/manual/en/collator.setstrength.php
252 *
253 * @throws MethodNotImplementedException
254 */
255 public function setStrength($strength)
256 {
257 throw new MethodNotImplementedException(__METHOD__);
258 }
259
260 /**
261 * Not supported. Sort array using specified collator and sort keys
262 *
263 * @param array &$arr Array of strings to sort
264 *
265 * @return Boolean True on success or false on failure
266 *
267 * @see http://www.php.net/manual/en/collator.sortwithsortkeys.php
268 *
269 * @throws MethodNotImplementedException
270 */
271 public function sortWithSortKeys(&$arr)
272 {
273 throw new MethodNotImplementedException(__METHOD__);
274 }
275
276 /**
277 * Not supported. Sort array using specified collator
278 *
279 * @param array &$arr Array of string to sort
280 * @param int $sortFlag Optional sorting type, one of the following:
281 * Collator::SORT_REGULAR
282 * Collator::SORT_NUMERIC
283 * Collator::SORT_STRING
284 *
285 * @return Boolean True on success or false on failure
286 *
287 * @see http://www.php.net/manual/en/collator.sort.php
288 *
289 * @throws MethodNotImplementedException
290 */
291 public function sort(&$arr, $sortFlag = self::SORT_REGULAR)
292 {
293 throw new MethodNotImplementedException(__METHOD__);
294 }
295}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/AmPmTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/AmPmTransformer.php
new file mode 100644
index 00000000..1a9601d8
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/AmPmTransformer.php
@@ -0,0 +1,46 @@
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 AM/PM markers format
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class AmPmTransformer extends Transformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 return $dateTime->format('A');
27 }
28
29 /**
30 * {@inheritDoc}
31 */
32 public function getReverseMatchingRegExp($length)
33 {
34 return 'AM|PM';
35 }
36
37 /**
38 * {@inheritDoc}
39 */
40 public function extractDateOptions($matched, $length)
41 {
42 return array(
43 'marker' => $matched
44 );
45 }
46}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfWeekTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfWeekTransformer.php
new file mode 100644
index 00000000..ee53a4e6
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfWeekTransformer.php
@@ -0,0 +1,59 @@
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 day of week format
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class DayOfWeekTransformer extends Transformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 $dayOfWeek = $dateTime->format('l');
27 switch ($length) {
28 case 4:
29 return $dayOfWeek;
30 case 5:
31 return $dayOfWeek[0];
32 default:
33 return substr($dayOfWeek, 0, 3);
34 }
35 }
36
37 /**
38 * {@inheritDoc}
39 */
40 public function getReverseMatchingRegExp($length)
41 {
42 switch ($length) {
43 case 4:
44 return 'Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday';
45 case 5:
46 return '[MTWFS]';
47 default:
48 return 'Mon|Tue|Wed|Thu|Fri|Sat|Sun';
49 }
50 }
51
52 /**
53 * {@inheritDoc}
54 */
55 public function extractDateOptions($matched, $length)
56 {
57 return array();
58 }
59}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfYearTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfYearTransformer.php
new file mode 100644
index 00000000..2c33888c
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfYearTransformer.php
@@ -0,0 +1,46 @@
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 day of year format
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class DayOfYearTransformer extends Transformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 $dayOfYear = $dateTime->format('z') + 1;
27
28 return $this->padLeft($dayOfYear, $length);
29 }
30
31 /**
32 * {@inheritDoc}
33 */
34 public function getReverseMatchingRegExp($length)
35 {
36 return '\d{'.$length.'}';
37 }
38
39 /**
40 * {@inheritDoc}
41 */
42 public function extractDateOptions($matched, $length)
43 {
44 return array();
45 }
46}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayTransformer.php
new file mode 100644
index 00000000..19d30e74
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayTransformer.php
@@ -0,0 +1,46 @@
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 day format
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class DayTransformer extends Transformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 return $this->padLeft($dateTime->format('j'), $length);
27 }
28
29 /**
30 * {@inheritDoc}
31 */
32 public function getReverseMatchingRegExp($length)
33 {
34 return 1 === $length ? '\d{1,2}' : '\d{'.$length.'}';
35 }
36
37 /**
38 * {@inheritDoc}
39 */
40 public function extractDateOptions($matched, $length)
41 {
42 return array(
43 'day' => (int) $matched,
44 );
45 }
46}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php
new file mode 100644
index 00000000..b89db363
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php
@@ -0,0 +1,356 @@
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
14use Symfony\Component\Intl\Exception\NotImplementedException;
15use Symfony\Component\Intl\Globals\IntlGlobals;
16use Symfony\Component\Intl\DateFormatter\DateFormat\MonthTransformer;
17
18/**
19 * Parser and formatter for date formats
20 *
21 * @author Igor Wiedler <igor@wiedler.ch>
22 */
23class FullTransformer
24{
25 private $quoteMatch = "'(?:[^']+|'')*'";
26 private $implementedChars = 'MLydQqhDEaHkKmsz';
27 private $notImplementedChars = 'GYuwWFgecSAZvVW';
28 private $regExp;
29
30 /**
31 * @var Transformer[]
32 */
33 private $transformers;
34
35 private $pattern;
36 private $timezone;
37
38 /**
39 * Constructor
40 *
41 * @param string $pattern The pattern to be used to format and/or parse values
42 * @param string $timezone The timezone to perform the date/time calculations
43 */
44 public function __construct($pattern, $timezone)
45 {
46 $this->pattern = $pattern;
47 $this->timezone = $timezone;
48
49 $implementedCharsMatch = $this->buildCharsMatch($this->implementedChars);
50 $notImplementedCharsMatch = $this->buildCharsMatch($this->notImplementedChars);
51 $this->regExp = "/($this->quoteMatch|$implementedCharsMatch|$notImplementedCharsMatch)/";
52
53 $this->transformers = array(
54 'M' => new MonthTransformer(),
55 'L' => new MonthTransformer(),
56 'y' => new YearTransformer(),
57 'd' => new DayTransformer(),
58 'q' => new QuarterTransformer(),
59 'Q' => new QuarterTransformer(),
60 'h' => new Hour1201Transformer(),
61 'D' => new DayOfYearTransformer(),
62 'E' => new DayOfWeekTransformer(),
63 'a' => new AmPmTransformer(),
64 'H' => new Hour2400Transformer(),
65 'K' => new Hour1200Transformer(),
66 'k' => new Hour2401Transformer(),
67 'm' => new MinuteTransformer(),
68 's' => new SecondTransformer(),
69 'z' => new TimeZoneTransformer(),
70 );
71 }
72
73 /**
74 * Return the array of Transformer objects
75 *
76 * @return Transformer[] Associative array of Transformer objects (format char => Transformer)
77 */
78 public function getTransformers()
79 {
80 return $this->transformers;
81 }
82
83 /**
84 * Format a DateTime using ICU dateformat pattern
85 *
86 * @param \DateTime $dateTime A DateTime object to be used to generate the formatted value
87 *
88 * @return string The formatted value
89 */
90 public function format(\DateTime $dateTime)
91 {
92 $that = $this;
93
94 $formatted = preg_replace_callback($this->regExp, function($matches) use ($that, $dateTime) {
95 return $that->formatReplace($matches[0], $dateTime);
96 }, $this->pattern);
97
98 return $formatted;
99 }
100
101 /**
102 * Return the formatted ICU value for the matched date characters
103 *
104 * @param string $dateChars The date characters to be replaced with a formatted ICU value
105 * @param DateTime $dateTime A DateTime object to be used to generate the formatted value
106 *
107 * @return string The formatted value
108 *
109 * @throws NotImplementedException When it encounters a not implemented date character
110 */
111 public function formatReplace($dateChars, $dateTime)
112 {
113 $length = strlen($dateChars);
114
115 if ($this->isQuoteMatch($dateChars)) {
116 return $this->replaceQuoteMatch($dateChars);
117 }
118
119 if (isset($this->transformers[$dateChars[0]])) {
120 $transformer = $this->transformers[$dateChars[0]];
121
122 return $transformer->format($dateTime, $length);
123 }
124
125 // handle unimplemented characters
126 if (false !== strpos($this->notImplementedChars, $dateChars[0])) {
127 throw new NotImplementedException(sprintf("Unimplemented date character '%s' in format '%s'", $dateChars[0], $this->pattern));
128 }
129 }
130
131 /**
132 * Parse a pattern based string to a timestamp value
133 *
134 * @param \DateTime $dateTime A configured DateTime object to use to perform the date calculation
135 * @param string $value String to convert to a time value
136 *
137 * @return int The corresponding Unix timestamp
138 *
139 * @throws \InvalidArgumentException When the value can not be matched with pattern
140 */
141 public function parse(\DateTime $dateTime, $value)
142 {
143 $reverseMatchingRegExp = $this->getReverseMatchingRegExp($this->pattern);
144 $reverseMatchingRegExp = '/^'.$reverseMatchingRegExp.'$/';
145
146 $options = array();
147
148 if (preg_match($reverseMatchingRegExp, $value, $matches)) {
149 $matches = $this->normalizeArray($matches);
150
151 foreach ($this->transformers as $char => $transformer) {
152 if (isset($matches[$char])) {
153 $length = strlen($matches[$char]['pattern']);
154 $options = array_merge($options, $transformer->extractDateOptions($matches[$char]['value'], $length));
155 }
156 }
157
158 // reset error code and message
159 IntlGlobals::setError(IntlGlobals::U_ZERO_ERROR);
160
161 return $this->calculateUnixTimestamp($dateTime, $options);
162 }
163
164 // behave like the intl extension
165 IntlGlobals::setError(IntlGlobals::U_PARSE_ERROR, 'Date parsing failed');
166
167 return false;
168 }
169
170 /**
171 * Retrieve a regular expression to match with a formatted value.
172 *
173 * @param string $pattern The pattern to create the reverse matching regular expression
174 *
175 * @return string The reverse matching regular expression with named captures being formed by the
176 * transformer index in the $transformer array
177 */
178 public function getReverseMatchingRegExp($pattern)
179 {
180 $that = $this;
181
182 $escapedPattern = preg_quote($pattern, '/');
183
184 // ICU 4.8 recognizes slash ("/") in a value to be parsed as a dash ("-") and vice-versa
185 // when parsing a date/time value
186 $escapedPattern = preg_replace('/\\\[\-|\/]/', '[\/\-]', $escapedPattern);
187
188 $reverseMatchingRegExp = preg_replace_callback($this->regExp, function($matches) use ($that) {
189 $length = strlen($matches[0]);
190 $transformerIndex = $matches[0][0];
191
192 $dateChars = $matches[0];
193 if ($that->isQuoteMatch($dateChars)) {
194 return $that->replaceQuoteMatch($dateChars);
195 }
196
197 $transformers = $that->getTransformers();
198 if (isset($transformers[$transformerIndex])) {
199 $transformer = $transformers[$transformerIndex];
200 $captureName = str_repeat($transformerIndex, $length);
201
202 return "(?P<$captureName>".$transformer->getReverseMatchingRegExp($length).')';
203 }
204 }, $escapedPattern);
205
206 return $reverseMatchingRegExp;
207 }
208
209 /**
210 * Check if the first char of a string is a single quote
211 *
212 * @param string $quoteMatch The string to check
213 *
214 * @return Boolean true if matches, false otherwise
215 */
216 public function isQuoteMatch($quoteMatch)
217 {
218 return ("'" === $quoteMatch[0]);
219 }
220
221 /**
222 * Replaces single quotes at the start or end of a string with two single quotes
223 *
224 * @param string $quoteMatch The string to replace the quotes
225 *
226 * @return string A string with the single quotes replaced
227 */
228 public function replaceQuoteMatch($quoteMatch)
229 {
230 if (preg_match("/^'+$/", $quoteMatch)) {
231 return str_replace("''", "'", $quoteMatch);
232 }
233
234 return str_replace("''", "'", substr($quoteMatch, 1, -1));
235 }
236
237 /**
238 * Builds a chars match regular expression
239 *
240 * @param string $specialChars A string of chars to build the regular expression
241 *
242 * @return string The chars match regular expression
243 */
244 protected function buildCharsMatch($specialChars)
245 {
246 $specialCharsArray = str_split($specialChars);
247
248 $specialCharsMatch = implode('|', array_map(function($char) {
249 return $char.'+';
250 }, $specialCharsArray));
251
252 return $specialCharsMatch;
253 }
254
255 /**
256 * Normalize a preg_replace match array, removing the numeric keys and returning an associative array
257 * with the value and pattern values for the matched Transformer
258 *
259 * @param array $data
260 *
261 * @return array
262 */
263 protected function normalizeArray(array $data)
264 {
265 $ret = array();
266
267 foreach ($data as $key => $value) {
268 if (!is_string($key)) {
269 continue;
270 }
271
272 $ret[$key[0]] = array(
273 'value' => $value,
274 'pattern' => $key
275 );
276 }
277
278 return $ret;
279 }
280
281 /**
282 * Calculates the Unix timestamp based on the matched values by the reverse matching regular
283 * expression of parse()
284 *
285 * @param \DateTime $dateTime The DateTime object to be used to calculate the timestamp
286 * @param array $options An array with the matched values to be used to calculate the timestamp
287 *
288 * @return Boolean|int The calculated timestamp or false if matched date is invalid
289 */
290 protected function calculateUnixTimestamp(\DateTime $dateTime, array $options)
291 {
292 $options = $this->getDefaultValueForOptions($options);
293
294 $year = $options['year'];
295 $month = $options['month'];
296 $day = $options['day'];
297 $hour = $options['hour'];
298 $hourInstance = $options['hourInstance'];
299 $minute = $options['minute'];
300 $second = $options['second'];
301 $marker = $options['marker'];
302 $timezone = $options['timezone'];
303
304 // If month is false, return immediately (intl behavior)
305 if (false === $month) {
306 IntlGlobals::setError(IntlGlobals::U_PARSE_ERROR, 'Date parsing failed');
307
308 return false;
309 }
310
311 // Normalize hour
312 if ($hourInstance instanceof HourTransformer) {
313 $hour = $hourInstance->normalizeHour($hour, $marker);
314 }
315
316 // Set the timezone if different from the default one
317 if (null !== $timezone && $timezone !== $this->timezone) {
318 $dateTime->setTimezone(new \DateTimeZone($timezone));
319 }
320
321 // Normalize yy year
322 preg_match_all($this->regExp, $this->pattern, $matches);
323 if (in_array('yy', $matches[0])) {
324 $dateTime->setTimestamp(time());
325 $year = $year > $dateTime->format('y') + 20 ? 1900 + $year : 2000 + $year;
326 }
327
328 $dateTime->setDate($year, $month, $day);
329 $dateTime->setTime($hour, $minute, $second);
330
331 return $dateTime->getTimestamp();
332 }
333
334 /**
335 * Add sensible default values for missing items in the extracted date/time options array. The values
336 * are base in the beginning of the Unix era
337 *
338 * @param array $options
339 *
340 * @return array
341 */
342 private function getDefaultValueForOptions(array $options)
343 {
344 return array(
345 'year' => isset($options['year']) ? $options['year'] : 1970,
346 'month' => isset($options['month']) ? $options['month'] : 1,
347 'day' => isset($options['day']) ? $options['day'] : 1,
348 'hour' => isset($options['hour']) ? $options['hour'] : 0,
349 'hourInstance' => isset($options['hourInstance']) ? $options['hourInstance'] : null,
350 'minute' => isset($options['minute']) ? $options['minute'] : 0,
351 'second' => isset($options['second']) ? $options['second'] : 0,
352 'marker' => isset($options['marker']) ? $options['marker'] : null,
353 'timezone' => isset($options['timezone']) ? $options['timezone'] : null,
354 );
355 }
356}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1200Transformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1200Transformer.php
new file mode 100644
index 00000000..8c8f5ef4
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1200Transformer.php
@@ -0,0 +1,62 @@
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 12 hour format (0-11)
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class Hour1200Transformer extends HourTransformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 $hourOfDay = $dateTime->format('g');
27 $hourOfDay = '12' == $hourOfDay ? '0' : $hourOfDay;
28
29 return $this->padLeft($hourOfDay, $length);
30 }
31
32 /**
33 * {@inheritDoc}
34 */
35 public function normalizeHour($hour, $marker = null)
36 {
37 if ('PM' === $marker) {
38 $hour += 12;
39 }
40
41 return $hour;
42 }
43
44 /**
45 * {@inheritDoc}
46 */
47 public function getReverseMatchingRegExp($length)
48 {
49 return '\d{1,2}';
50 }
51
52 /**
53 * {@inheritDoc}
54 */
55 public function extractDateOptions($matched, $length)
56 {
57 return array(
58 'hour' => (int) $matched,
59 'hourInstance' => $this
60 );
61 }
62}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1201Transformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1201Transformer.php
new file mode 100644
index 00000000..a8c43702
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1201Transformer.php
@@ -0,0 +1,62 @@
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 12 hour format (1-12)
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class Hour1201Transformer extends HourTransformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 return $this->padLeft($dateTime->format('g'), $length);
27 }
28
29 /**
30 * {@inheritDoc}
31 */
32 public function normalizeHour($hour, $marker = null)
33 {
34 if ('PM' !== $marker && 12 === $hour) {
35 $hour = 0;
36 } elseif ('PM' === $marker && 12 !== $hour) {
37 // If PM and hour is not 12 (1-12), sum 12 hour
38 $hour += 12;
39 }
40
41 return $hour;
42 }
43
44 /**
45 * {@inheritDoc}
46 */
47 public function getReverseMatchingRegExp($length)
48 {
49 return '\d{1,2}';
50 }
51
52 /**
53 * {@inheritDoc}
54 */
55 public function extractDateOptions($matched, $length)
56 {
57 return array(
58 'hour' => (int) $matched,
59 'hourInstance' => $this
60 );
61 }
62}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2400Transformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2400Transformer.php
new file mode 100644
index 00000000..8f22da13
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2400Transformer.php
@@ -0,0 +1,61 @@
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 24 hour format (0-23)
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class Hour2400Transformer extends HourTransformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 return $this->padLeft($dateTime->format('G'), $length);
27 }
28
29 /**
30 * {@inheritDoc}
31 */
32 public function normalizeHour($hour, $marker = null)
33 {
34 if ('AM' == $marker) {
35 $hour = 0;
36 } elseif ('PM' == $marker) {
37 $hour = 12;
38 }
39
40 return $hour;
41 }
42
43 /**
44 * {@inheritDoc}
45 */
46 public function getReverseMatchingRegExp($length)
47 {
48 return '\d{1,2}';
49 }
50
51 /**
52 * {@inheritDoc}
53 */
54 public function extractDateOptions($matched, $length)
55 {
56 return array(
57 'hour' => (int) $matched,
58 'hourInstance' => $this
59 );
60 }
61}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2401Transformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2401Transformer.php
new file mode 100644
index 00000000..b0f486b9
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2401Transformer.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 24 hour format (1-24)
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class Hour2401Transformer extends HourTransformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 $hourOfDay = $dateTime->format('G');
27 $hourOfDay = ('0' == $hourOfDay) ? '24' : $hourOfDay;
28
29 return $this->padLeft($hourOfDay, $length);
30 }
31
32 /**
33 * {@inheritDoc}
34 */
35 public function normalizeHour($hour, $marker = null)
36 {
37 if ((null === $marker && 24 === $hour) || 'AM' == $marker) {
38 $hour = 0;
39 } elseif ('PM' == $marker) {
40 $hour = 12;
41 }
42
43 return $hour;
44 }
45
46 /**
47 * {@inheritDoc}
48 */
49 public function getReverseMatchingRegExp($length)
50 {
51 return '\d{1,2}';
52 }
53
54 /**
55 * {@inheritDoc}
56 */
57 public function extractDateOptions($matched, $length)
58 {
59 return array(
60 'hour' => (int) $matched,
61 'hourInstance' => $this
62 );
63 }
64}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/HourTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/HourTransformer.php
new file mode 100644
index 00000000..51097d92
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/HourTransformer.php
@@ -0,0 +1,30 @@
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 * Base class for hour transformers
16 *
17 * @author Eriksen Costa <eriksen.costa@infranology.com.br>
18 */
19abstract class HourTransformer extends Transformer
20{
21 /**
22 * Returns a normalized hour value suitable for the hour transformer type
23 *
24 * @param int $hour The hour value
25 * @param string $marker An optional AM/PM marker
26 *
27 * @return int The normalized hour value
28 */
29 abstract public function normalizeHour($hour, $marker = null);
30}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/MinuteTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/MinuteTransformer.php
new file mode 100644
index 00000000..b48de292
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/MinuteTransformer.php
@@ -0,0 +1,48 @@
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 minute format
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class MinuteTransformer extends Transformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 $minuteOfHour = (int) $dateTime->format('i');
27
28 return $this->padLeft($minuteOfHour, $length);
29 }
30
31 /**
32 * {@inheritDoc}
33 */
34 public function getReverseMatchingRegExp($length)
35 {
36 return 1 === $length ? '\d{1,2}' : '\d{'.$length.'}';
37 }
38
39 /**
40 * {@inheritDoc}
41 */
42 public function extractDateOptions($matched, $length)
43 {
44 return array(
45 'minute' => (int) $matched,
46 );
47 }
48}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/MonthTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/MonthTransformer.php
new file mode 100644
index 00000000..30c15af7
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/MonthTransformer.php
@@ -0,0 +1,143 @@
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 month format
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class MonthTransformer extends Transformer
20{
21 /**
22 * @var array
23 */
24 protected static $months = array(
25 'January',
26 'February',
27 'March',
28 'April',
29 'May',
30 'June',
31 'July',
32 'August',
33 'September',
34 'October',
35 'November',
36 'December'
37 );
38
39 /**
40 * Short months names (first 3 letters)
41 * @var array
42 */
43 protected static $shortMonths = array();
44
45 /**
46 * Flipped $months array, $name => $index
47 * @var array
48 */
49 protected static $flippedMonths = array();
50
51 /**
52 * Flipped $shortMonths array, $name => $index
53 * @var array
54 */
55 protected static $flippedShortMonths = array();
56
57 /**
58 * Constructor
59 */
60 public function __construct()
61 {
62 if (0 === count(self::$shortMonths)) {
63 self::$shortMonths = array_map(function($month) {
64 return substr($month, 0, 3);
65 }, self::$months);
66
67 self::$flippedMonths = array_flip(self::$months);
68 self::$flippedShortMonths = array_flip(self::$shortMonths);
69 }
70 }
71
72 /**
73 * {@inheritDoc}
74 */
75 public function format(\DateTime $dateTime, $length)
76 {
77 $matchLengthMap = array(
78 1 => 'n',
79 2 => 'm',
80 3 => 'M',
81 4 => 'F',
82 );
83
84 if (isset($matchLengthMap[$length])) {
85 return $dateTime->format($matchLengthMap[$length]);
86 }
87
88 if (5 === $length) {
89 return substr($dateTime->format('M'), 0, 1);
90 }
91
92 return $this->padLeft($dateTime->format('m'), $length);
93 }
94
95 /**
96 * {@inheritDoc}
97 */
98 public function getReverseMatchingRegExp($length)
99 {
100 switch ($length) {
101 case 1:
102 $regExp = '\d{1,2}';
103 break;
104 case 3:
105 $regExp = implode('|', self::$shortMonths);
106 break;
107 case 4:
108 $regExp = implode('|', self::$months);
109 break;
110 case 5:
111 $regExp = '[JFMASOND]';
112 break;
113 default:
114 $regExp = '\d{'.$length.'}';
115 break;
116 }
117
118 return $regExp;
119 }
120
121 /**
122 * {@inheritDoc}
123 */
124 public function extractDateOptions($matched, $length)
125 {
126 if (!is_numeric($matched)) {
127 if (3 === $length) {
128 $matched = self::$flippedShortMonths[$matched] + 1;
129 } elseif (4 === $length) {
130 $matched = self::$flippedMonths[$matched] + 1;
131 } elseif (5 === $length) {
132 // IntlDateFormatter::parse() always returns false for MMMMM or LLLLL
133 $matched = false;
134 }
135 } else {
136 $matched = (int) $matched;
137 }
138
139 return array(
140 'month' => $matched,
141 );
142 }
143}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/QuarterTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/QuarterTransformer.php
new file mode 100644
index 00000000..8e83dc75
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/QuarterTransformer.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 quarter format
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class QuarterTransformer extends Transformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 $month = (int) $dateTime->format('n');
27 $quarter = (int) floor(($month - 1) / 3) + 1;
28 switch ($length) {
29 case 1:
30 case 2:
31 return $this->padLeft($quarter, $length);
32 case 3:
33 return 'Q'.$quarter;
34 default:
35 $map = array(1 => '1st quarter', 2 => '2nd quarter', 3 => '3rd quarter', 4 => '4th quarter');
36
37 return $map[$quarter];
38 }
39 }
40
41 /**
42 * {@inheritDoc}
43 */
44 public function getReverseMatchingRegExp($length)
45 {
46 switch ($length) {
47 case 1:
48 case 2:
49 return '\d{'.$length.'}';
50 case 3:
51 return 'Q\d';
52 default:
53 return '(?:1st|2nd|3rd|4th) quarter';
54 }
55 }
56
57 /**
58 * {@inheritDoc}
59 */
60 public function extractDateOptions($matched, $length)
61 {
62 return array();
63 }
64}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/SecondTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/SecondTransformer.php
new file mode 100644
index 00000000..ccbcdb41
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/SecondTransformer.php
@@ -0,0 +1,48 @@
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 the second format
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class SecondTransformer extends Transformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 $secondOfMinute = (int) $dateTime->format('s');
27
28 return $this->padLeft($secondOfMinute, $length);
29 }
30
31 /**
32 * {@inheritDoc}
33 */
34 public function getReverseMatchingRegExp($length)
35 {
36 return 1 === $length ? '\d{1,2}' : '\d{'.$length.'}';
37 }
38
39 /**
40 * {@inheritDoc}
41 */
42 public function extractDateOptions($matched, $length)
43 {
44 return array(
45 'second' => (int) $matched,
46 );
47 }
48}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php
new file mode 100644
index 00000000..7d74bd36
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php
@@ -0,0 +1,99 @@
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
14use Symfony\Component\Intl\Exception\NotImplementedException;
15
16/**
17 * Parser and formatter for time zone format
18 *
19 * @author Igor Wiedler <igor@wiedler.ch>
20 */
21class TimeZoneTransformer extends Transformer
22{
23 /**
24 * {@inheritDoc}
25 *
26 * @throws NotImplementedException When time zone is different than UTC or GMT (Etc/GMT)
27 */
28 public function format(\DateTime $dateTime, $length)
29 {
30 $timeZone = substr($dateTime->getTimezone()->getName(), 0, 3);
31
32 if (!in_array($timeZone, array('Etc', 'UTC'))) {
33 throw new NotImplementedException('Time zone different than GMT or UTC is not supported as a formatting output.');
34 }
35
36 // From ICU >= 4.8, the zero offset is not more used, example: GMT instead of GMT+00:00
37 $format = (0 !== (int) $dateTime->format('O')) ? '\G\M\TP' : '\G\M\T';
38
39 return $dateTime->format($format);
40 }
41
42 /**
43 * {@inheritDoc}
44 */
45 public function getReverseMatchingRegExp($length)
46 {
47 return 'GMT[+-]\d{2}:?\d{2}';
48 }
49
50 /**
51 * {@inheritDoc}
52 */
53 public function extractDateOptions($matched, $length)
54 {
55 return array(
56 'timezone' => self::getEtcTimeZoneId($matched)
57 );
58 }
59
60 /**
61 * Get an Etc/GMT timezone identifier for the specified timezone
62 *
63 * The PHP documentation for timezones states to not use the 'Other' time zones because them exists
64 * "for backwards compatibility". However all Etc/GMT time zones are in the tz database 'etcetera' file,
65 * which indicates they are not deprecated (neither are old names).
66 *
67 * Only GMT, Etc/Universal, Etc/Zulu, Etc/Greenwich, Etc/GMT-0, Etc/GMT+0 and Etc/GMT0 are old names and
68 * are linked to Etc/GMT or Etc/UTC.
69 *
70 * @param string $formattedTimeZone A GMT timezone string (GMT-03:00, e.g.)
71 *
72 * @return string A timezone identifier
73 *
74 * @see http://php.net/manual/en/timezones.others.php
75 * @see http://www.twinsun.com/tz/tz-link.htm
76 *
77 * @throws NotImplementedException When the GMT time zone have minutes offset different than zero
78 * @throws \InvalidArgumentException When the value can not be matched with pattern
79 */
80 public static function getEtcTimeZoneId($formattedTimeZone)
81 {
82 if (preg_match('/GMT(?P<signal>[+-])(?P<hours>\d{2}):?(?P<minutes>\d{2})/', $formattedTimeZone, $matches)) {
83 $hours = (int) $matches['hours'];
84 $minutes = (int) $matches['minutes'];
85 $signal = $matches['signal'] == '-' ? '+' : '-';
86
87 if (0 < $minutes) {
88 throw new NotImplementedException(sprintf(
89 'It is not possible to use a GMT time zone with minutes offset different than zero (0). GMT time zone tried: %s.',
90 $formattedTimeZone
91 ));
92 }
93
94 return 'Etc/GMT'.($hours !== 0 ? $signal.$hours : '');
95 }
96
97 throw new \InvalidArgumentException('The GMT time zone \'%s\' does not match with the supported formats GMT[+-]HH:MM or GMT[+-]HHMM.');
98 }
99}
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}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/YearTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/YearTransformer.php
new file mode 100644
index 00000000..c3bd699d
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/YearTransformer.php
@@ -0,0 +1,50 @@
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 year format
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class YearTransformer extends Transformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 if (2 === $length) {
27 return $dateTime->format('y');
28 }
29
30 return $this->padLeft($dateTime->format('Y'), $length);
31 }
32
33 /**
34 * {@inheritDoc}
35 */
36 public function getReverseMatchingRegExp($length)
37 {
38 return 2 === $length ? '\d{2}' : '\d{4}';
39 }
40
41 /**
42 * {@inheritDoc}
43 */
44 public function extractDateOptions($matched, $length)
45 {
46 return array(
47 'year' => (int) $matched,
48 );
49 }
50}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php
new file mode 100644
index 00000000..33a499a8
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php
@@ -0,0 +1,631 @@
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;
13
14use Symfony\Component\Intl\Globals\IntlGlobals;
15use Symfony\Component\Intl\DateFormatter\DateFormat\FullTransformer;
16use Symfony\Component\Intl\Exception\MethodNotImplementedException;
17use Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException;
18use Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException;
19use Symfony\Component\Intl\Locale\Locale;
20
21/**
22 * Replacement for PHP's native {@link \IntlDateFormatter} class.
23 *
24 * The only methods currently supported in this class are:
25 *
26 * - {@link __construct}
27 * - {@link create}
28 * - {@link format}
29 * - {@link getCalendar}
30 * - {@link getDateType}
31 * - {@link getErrorCode}
32 * - {@link getErrorMessage}
33 * - {@link getLocale}
34 * - {@link getPattern}
35 * - {@link getTimeType}
36 * - {@link getTimeZoneId}
37 * - {@link isLenient}
38 * - {@link parse}
39 * - {@link setLenient}
40 * - {@link setPattern}
41 * - {@link setTimeZoneId}
42 * - {@link setTimeZone}
43 *
44 * @author Igor Wiedler <igor@wiedler.ch>
45 * @author Bernhard Schussek <bschussek@gmail.com>
46 */
47class IntlDateFormatter
48{
49 /**
50 * The error code from the last operation
51 *
52 * @var integer
53 */
54 protected $errorCode = IntlGlobals::U_ZERO_ERROR;
55
56 /**
57 * The error message from the last operation
58 *
59 * @var string
60 */
61 protected $errorMessage = 'U_ZERO_ERROR';
62
63 /* date/time format types */
64 const NONE = -1;
65 const FULL = 0;
66 const LONG = 1;
67 const MEDIUM = 2;
68 const SHORT = 3;
69
70 /* calendar formats */
71 const TRADITIONAL = 0;
72 const GREGORIAN = 1;
73
74 /**
75 * Patterns used to format the date when no pattern is provided
76 *
77 * @var array
78 */
79 private $defaultDateFormats = array(
80 self::NONE => '',
81 self::FULL => 'EEEE, LLLL d, y',
82 self::LONG => 'LLLL d, y',
83 self::MEDIUM => 'LLL d, y',
84 self::SHORT => 'M/d/yy',
85 );
86
87 /**
88 * Patterns used to format the time when no pattern is provided
89 *
90 * @var array
91 */
92 private $defaultTimeFormats = array(
93 self::FULL => 'h:mm:ss a zzzz',
94 self::LONG => 'h:mm:ss a z',
95 self::MEDIUM => 'h:mm:ss a',
96 self::SHORT => 'h:mm a',
97 );
98
99 /**
100 * @var int
101 */
102 private $datetype;
103
104 /**
105 * @var int
106 */
107 private $timetype;
108
109 /**
110 * @var string
111 */
112 private $pattern;
113
114 /**
115 * @var \DateTimeZone
116 */
117 private $dateTimeZone;
118
119 /**
120 * @var Boolean
121 */
122 private $unitializedTimeZoneId = false;
123
124 /**
125 * @var string
126 */
127 private $timeZoneId;
128
129 /**
130 * Constructor
131 *
132 * @param string $locale The locale code. The only currently supported locale is "en".
133 * @param int $datetype Type of date formatting, one of the format type constants
134 * @param int $timetype Type of time formatting, one of the format type constants
135 * @param string $timezone Timezone identifier
136 * @param int $calendar Calendar to use for formatting or parsing. The only currently
137 * supported value is IntlDateFormatter::GREGORIAN.
138 * @param string $pattern Optional pattern to use when formatting
139 *
140 * @see http://www.php.net/manual/en/intldateformatter.create.php
141 * @see http://userguide.icu-project.org/formatparse/datetime
142 *
143 * @throws MethodArgumentValueNotImplementedException When $locale different than "en" is passed
144 * @throws MethodArgumentValueNotImplementedException When $calendar different than GREGORIAN is passed
145 */
146 public function __construct($locale, $datetype, $timetype, $timezone = null, $calendar = self::GREGORIAN, $pattern = null)
147 {
148 if ('en' !== $locale) {
149 throw new MethodArgumentValueNotImplementedException(__METHOD__, 'locale', $locale, 'Only the locale "en" is supported');
150 }
151
152 if (self::GREGORIAN !== $calendar) {
153 throw new MethodArgumentValueNotImplementedException(__METHOD__, 'calendar', $calendar, 'Only the GREGORIAN calendar is supported');
154 }
155
156 $this->datetype = $datetype;
157 $this->timetype = $timetype;
158
159 $this->setPattern($pattern);
160 $this->setTimeZoneId($timezone);
161 }
162
163 /**
164 * Static constructor
165 *
166 * @param string $locale The locale code. The only currently supported locale is "en".
167 * @param int $datetype Type of date formatting, one of the format type constants
168 * @param int $timetype Type of time formatting, one of the format type constants
169 * @param string $timezone Timezone identifier
170 * @param int $calendar Calendar to use for formatting or parsing; default is Gregorian.
171 * One of the calendar constants.
172 * @param string $pattern Optional pattern to use when formatting
173 *
174 * @return IntlDateFormatter
175 *
176 * @see http://www.php.net/manual/en/intldateformatter.create.php
177 * @see http://userguide.icu-project.org/formatparse/datetime
178 *
179 * @throws MethodArgumentValueNotImplementedException When $locale different than "en" is passed
180 * @throws MethodArgumentValueNotImplementedException When $calendar different than GREGORIAN is passed
181 */
182 public static function create($locale, $datetype, $timetype, $timezone = null, $calendar = self::GREGORIAN, $pattern = null)
183 {
184 return new self($locale, $datetype, $timetype, $timezone, $calendar, $pattern);
185 }
186
187 /**
188 * Format the date/time value (timestamp) as a string
189 *
190 * @param integer|\DateTime $timestamp The timestamp to format. \DateTime objects
191 * are supported as of PHP 5.3.4.
192 *
193 * @return string|Boolean The formatted value or false if formatting failed.
194 *
195 * @see http://www.php.net/manual/en/intldateformatter.format.php
196 *
197 * @throws MethodArgumentValueNotImplementedException If one of the formatting characters is not implemented
198 */
199 public function format($timestamp)
200 {
201 // intl allows timestamps to be passed as arrays - we don't
202 if (is_array($timestamp)) {
203 $message = version_compare(PHP_VERSION, '5.3.4', '>=') ?
204 'Only integer unix timestamps and DateTime objects are supported' :
205 'Only integer unix timestamps are supported';
206
207 throw new MethodArgumentValueNotImplementedException(__METHOD__, 'timestamp', $timestamp, $message);
208 }
209
210 // behave like the intl extension
211 $argumentError = null;
212 if (version_compare(PHP_VERSION, '5.3.4', '<') && !is_int($timestamp)) {
213 $argumentError = 'datefmt_format: takes either an array or an integer timestamp value ';
214 } elseif (version_compare(PHP_VERSION, '5.3.4', '>=') && !is_int($timestamp) && !$timestamp instanceof \DateTime) {
215 $argumentError = 'datefmt_format: takes either an array or an integer timestamp value or a DateTime object';
216 if (version_compare(PHP_VERSION, '5.5.0-dev', '>=') && !is_int($timestamp)) {
217 $argumentError = sprintf('datefmt_format: string \'%s\' is not numeric, which would be required for it to be a valid date', $timestamp);
218 }
219 }
220
221 if (null !== $argumentError) {
222 IntlGlobals::setError(IntlGlobals::U_ILLEGAL_ARGUMENT_ERROR, $argumentError);
223 $this->errorCode = IntlGlobals::getErrorCode();
224 $this->errorMessage = IntlGlobals::getErrorMessage();
225
226 return false;
227 }
228
229 // As of PHP 5.3.4, IntlDateFormatter::format() accepts DateTime instances
230 if (version_compare(PHP_VERSION, '5.3.4', '>=') && $timestamp instanceof \DateTime) {
231 $timestamp = $timestamp->getTimestamp();
232 }
233
234 $transformer = new FullTransformer($this->getPattern(), $this->getTimeZoneId());
235 $formatted = $transformer->format($this->createDateTime($timestamp));
236
237 // behave like the intl extension
238 IntlGlobals::setError(IntlGlobals::U_ZERO_ERROR);
239 $this->errorCode = IntlGlobals::getErrorCode();
240 $this->errorMessage = IntlGlobals::getErrorMessage();
241
242 return $formatted;
243 }
244
245 /**
246 * Not supported. Formats an object
247 *
248 * @param object $object
249 * @param mixed $format
250 * @param string $locale
251 *
252 * @return string The formatted value
253 *
254 * @see http://www.php.net/manual/en/intldateformatter.formatobject.php
255 *
256 * @throws MethodNotImplementedException
257 */
258 public function formatObject($object, $format = null, $locale = null)
259 {
260 throw new MethodNotImplementedException(__METHOD__);
261 }
262
263 /**
264 * Returns the formatter's calendar
265 *
266 * @return int The calendar being used by the formatter. Currently always returns
267 * IntlDateFormatter::GREGORIAN.
268 *
269 * @see http://www.php.net/manual/en/intldateformatter.getcalendar.php
270 */
271 public function getCalendar()
272 {
273 return self::GREGORIAN;
274 }
275
276 /**
277 * Not supported. Returns the formatter's calendar object
278 *
279 * @return object The calendar's object being used by the formatter
280 *
281 * @see http://www.php.net/manual/en/intldateformatter.getcalendarobject.php
282 *
283 * @throws MethodNotImplementedException
284 */
285 public function getCalendarObject()
286 {
287 throw new MethodNotImplementedException(__METHOD__);
288 }
289
290 /**
291 * Returns the formatter's datetype
292 *
293 * @return int The current value of the formatter
294 *
295 * @see http://www.php.net/manual/en/intldateformatter.getdatetype.php
296 */
297 public function getDateType()
298 {
299 return $this->datetype;
300 }
301
302 /**
303 * Returns formatter's last error code. Always returns the U_ZERO_ERROR class constant value
304 *
305 * @return int The error code from last formatter call
306 *
307 * @see http://www.php.net/manual/en/intldateformatter.geterrorcode.php
308 */
309 public function getErrorCode()
310 {
311 return $this->errorCode;
312 }
313
314 /**
315 * Returns formatter's last error message. Always returns the U_ZERO_ERROR_MESSAGE class constant value
316 *
317 * @return string The error message from last formatter call
318 *
319 * @see http://www.php.net/manual/en/intldateformatter.geterrormessage.php
320 */
321 public function getErrorMessage()
322 {
323 return $this->errorMessage;
324 }
325
326 /**
327 * Returns the formatter's locale
328 *
329 * @param int $type Not supported. The locale name type to return (Locale::VALID_LOCALE or Locale::ACTUAL_LOCALE)
330 *
331 * @return string The locale used to create the formatter. Currently always
332 * returns "en".
333 *
334 * @see http://www.php.net/manual/en/intldateformatter.getlocale.php
335 */
336 public function getLocale($type = Locale::ACTUAL_LOCALE)
337 {
338 return 'en';
339 }
340
341 /**
342 * Returns the formatter's pattern
343 *
344 * @return string The pattern string used by the formatter
345 *
346 * @see http://www.php.net/manual/en/intldateformatter.getpattern.php
347 */
348 public function getPattern()
349 {
350 return $this->pattern;
351 }
352
353 /**
354 * Returns the formatter's time type
355 *
356 * @return string The time type used by the formatter
357 *
358 * @see http://www.php.net/manual/en/intldateformatter.gettimetype.php
359 */
360 public function getTimeType()
361 {
362 return $this->timetype;
363 }
364
365 /**
366 * Returns the formatter's timezone identifier
367 *
368 * @return string The timezone identifier used by the formatter
369 *
370 * @see http://www.php.net/manual/en/intldateformatter.gettimezoneid.php
371 */
372 public function getTimeZoneId()
373 {
374 if (!$this->unitializedTimeZoneId) {
375 return $this->timeZoneId;
376 }
377
378 // In PHP 5.5 default timezone depends on `date_default_timezone_get()` method
379 if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
380 return date_default_timezone_get();
381 }
382
383 return null;
384 }
385
386 /**
387 * Not supported. Returns the formatter's timezone
388 *
389 * @return mixed The timezone used by the formatter
390 *
391 * @see http://www.php.net/manual/en/intldateformatter.gettimezone.php
392 *
393 * @throws MethodNotImplementedException
394 */
395 public function getTimeZone()
396 {
397 throw new MethodNotImplementedException(__METHOD__);
398 }
399
400 /**
401 * Returns whether the formatter is lenient
402 *
403 * @return Boolean Currently always returns false.
404 *
405 * @see http://www.php.net/manual/en/intldateformatter.islenient.php
406 *
407 * @throws MethodNotImplementedException
408 */
409 public function isLenient()
410 {
411 return false;
412 }
413
414 /**
415 * Not supported. Parse string to a field-based time value
416 *
417 * @param string $value String to convert to a time value
418 * @param int $position Position at which to start the parsing in $value (zero-based).
419 * If no error occurs before $value is consumed, $parse_pos will
420 * contain -1 otherwise it will contain the position at which parsing
421 * ended. If $parse_pos > strlen($value), the parse fails immediately.
422 *
423 * @return string Localtime compatible array of integers: contains 24 hour clock value in tm_hour field
424 *
425 * @see http://www.php.net/manual/en/intldateformatter.localtime.php
426 *
427 * @throws MethodNotImplementedException
428 */
429 public function localtime($value, &$position = 0)
430 {
431 throw new MethodNotImplementedException(__METHOD__);
432 }
433
434 /**
435 * Parse string to a timestamp value
436 *
437 * @param string $value String to convert to a time value
438 * @param int $position Not supported. Position at which to start the parsing in $value (zero-based).
439 * If no error occurs before $value is consumed, $parse_pos will
440 * contain -1 otherwise it will contain the position at which parsing
441 * ended. If $parse_pos > strlen($value), the parse fails immediately.
442 *
443 * @return string Parsed value as a timestamp
444 *
445 * @see http://www.php.net/manual/en/intldateformatter.parse.php
446 *
447 * @throws MethodArgumentNotImplementedException When $position different than null, behavior not implemented
448 */
449 public function parse($value, &$position = null)
450 {
451 // We don't calculate the position when parsing the value
452 if (null !== $position) {
453 throw new MethodArgumentNotImplementedException(__METHOD__, 'position');
454 }
455
456 $dateTime = $this->createDateTime(0);
457 $transformer = new FullTransformer($this->getPattern(), $this->getTimeZoneId());
458
459 $timestamp = $transformer->parse($dateTime, $value);
460
461 // behave like the intl extension. FullTransformer::parse() set the proper error
462 $this->errorCode = IntlGlobals::getErrorCode();
463 $this->errorMessage = IntlGlobals::getErrorMessage();
464
465 return $timestamp;
466 }
467
468 /**
469 * Not supported. Set the formatter's calendar
470 *
471 * @param string $calendar The calendar to use. Default is IntlDateFormatter::GREGORIAN.
472 *
473 * @return Boolean true on success or false on failure
474 *
475 * @see http://www.php.net/manual/en/intldateformatter.setcalendar.php
476 *
477 * @throws MethodNotImplementedException
478 */
479 public function setCalendar($calendar)
480 {
481 throw new MethodNotImplementedException(__METHOD__);
482 }
483
484 /**
485 * Set the leniency of the parser
486 *
487 * Define if the parser is strict or lenient in interpreting inputs that do not match the pattern
488 * exactly. Enabling lenient parsing allows the parser to accept otherwise flawed date or time
489 * patterns, parsing as much as possible to obtain a value. Extra space, unrecognized tokens, or
490 * invalid values ("February 30th") are not accepted.
491 *
492 * @param Boolean $lenient Sets whether the parser is lenient or not. Currently
493 * only false (strict) is supported.
494 *
495 * @return Boolean true on success or false on failure
496 *
497 * @see http://www.php.net/manual/en/intldateformatter.setlenient.php
498 *
499 * @throws MethodArgumentValueNotImplementedException When $lenient is true
500 */
501 public function setLenient($lenient)
502 {
503 if ($lenient) {
504 throw new MethodArgumentValueNotImplementedException(__METHOD__, 'lenient', $lenient, 'Only the strict parser is supported');
505 }
506
507 return true;
508 }
509
510 /**
511 * Set the formatter's pattern
512 *
513 * @param string $pattern A pattern string in conformance with the ICU IntlDateFormatter documentation
514 *
515 * @return Boolean true on success or false on failure
516 *
517 * @see http://www.php.net/manual/en/intldateformatter.setpattern.php
518 * @see http://userguide.icu-project.org/formatparse/datetime
519 */
520 public function setPattern($pattern)
521 {
522 if (null === $pattern) {
523 $pattern = $this->getDefaultPattern();
524 }
525
526 $this->pattern = $pattern;
527
528 return true;
529 }
530
531 /**
532 * Set the formatter's timezone identifier
533 *
534 * @param string $timeZoneId The time zone ID string of the time zone to use.
535 * If NULL or the empty string, the default time zone for the
536 * runtime is used.
537 *
538 * @return Boolean true on success or false on failure
539 *
540 * @see http://www.php.net/manual/en/intldateformatter.settimezoneid.php
541 */
542 public function setTimeZoneId($timeZoneId)
543 {
544 if (null === $timeZoneId) {
545 // In PHP 5.5 if $timeZoneId is null it fallbacks to `date_default_timezone_get()` method
546 if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
547 $timeZoneId = date_default_timezone_get();
548 } else {
549 // TODO: changes were made to ext/intl in PHP 5.4.4 release that need to be investigated since it will
550 // use ini's date.timezone when the time zone is not provided. As a not well tested workaround, uses UTC.
551 // See the first two items of the commit message for more information:
552 // https://github.com/php/php-src/commit/eb346ef0f419b90739aadfb6cc7b7436c5b521d9
553 $timeZoneId = getenv('TZ') ?: 'UTC';
554 }
555
556 $this->unitializedTimeZoneId = true;
557 }
558
559 // Backup original passed time zone
560 $timeZone = $timeZoneId;
561
562 // Get an Etc/GMT time zone that is accepted for \DateTimeZone
563 if ('GMT' !== $timeZoneId && 0 === strpos($timeZoneId, 'GMT')) {
564 try {
565 $timeZoneId = DateFormat\TimeZoneTransformer::getEtcTimeZoneId($timeZoneId);
566 } catch (\InvalidArgumentException $e) {
567 // Does nothing, will fallback to UTC
568 }
569 }
570
571 try {
572 $this->dateTimeZone = new \DateTimeZone($timeZoneId);
573 } catch (\Exception $e) {
574 $this->dateTimeZone = new \DateTimeZone('UTC');
575 }
576
577 $this->timeZoneId = $timeZone;
578
579 return true;
580 }
581
582 /**
583 * This method was added in PHP 5.5 as replacement for `setTimeZoneId()`
584 *
585 * @param mixed $timeZone
586 *
587 * @return Boolean true on success or false on failure
588 *
589 * @see http://www.php.net/manual/en/intldateformatter.settimezone.php
590 */
591 public function setTimeZone($timeZone)
592 {
593 return $this->setTimeZoneId($timeZone);
594 }
595
596 /**
597 * Create and returns a DateTime object with the specified timestamp and with the
598 * current time zone
599 *
600 * @param int $timestamp
601 *
602 * @return \DateTime
603 */
604 protected function createDateTime($timestamp)
605 {
606 $dateTime = new \DateTime();
607 $dateTime->setTimestamp($timestamp);
608 $dateTime->setTimezone($this->dateTimeZone);
609
610 return $dateTime;
611 }
612
613 /**
614 * Returns a pattern string based in the datetype and timetype values
615 *
616 * @return string
617 */
618 protected function getDefaultPattern()
619 {
620 $patternParts = array();
621 if (self::NONE !== $this->datetype) {
622 $patternParts[] = $this->defaultDateFormats[$this->datetype];
623 }
624 if (self::NONE !== $this->timetype) {
625 $patternParts[] = $this->defaultTimeFormats[$this->timetype];
626 }
627 $pattern = implode(' ', $patternParts);
628
629 return $pattern;
630 }
631}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Exception/BadMethodCallException.php b/vendor/symfony/intl/Symfony/Component/Intl/Exception/BadMethodCallException.php
new file mode 100644
index 00000000..ca79729f
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Exception/BadMethodCallException.php
@@ -0,0 +1,21 @@
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\Exception;
13
14/**
15 * Base BadMethodCallException for the Intl component.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface
20{
21}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Exception/ExceptionInterface.php b/vendor/symfony/intl/Symfony/Component/Intl/Exception/ExceptionInterface.php
new file mode 100644
index 00000000..4fc076ca
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Exception/ExceptionInterface.php
@@ -0,0 +1,21 @@
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\Exception;
13
14/**
15 * Base ExceptionInterface for the Intl component.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19interface ExceptionInterface
20{
21}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Exception/InvalidArgumentException.php b/vendor/symfony/intl/Symfony/Component/Intl/Exception/InvalidArgumentException.php
new file mode 100644
index 00000000..10f69ee3
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Exception/InvalidArgumentException.php
@@ -0,0 +1,21 @@
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\Exception;
13
14/**
15 * InvalidArgumentException for the Intl component.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
20{
21}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Exception/MethodArgumentNotImplementedException.php b/vendor/symfony/intl/Symfony/Component/Intl/Exception/MethodArgumentNotImplementedException.php
new file mode 100644
index 00000000..570609d0
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Exception/MethodArgumentNotImplementedException.php
@@ -0,0 +1,32 @@
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\Exception;
13
14use Symfony\Component\Intl\Exception\NotImplementedException;
15
16/**
17 * @author Eriksen Costa <eriksen.costa@infranology.com.br>
18 */
19class MethodArgumentNotImplementedException extends NotImplementedException
20{
21 /**
22 * Constructor
23 *
24 * @param string $methodName The method name that raised the exception
25 * @param string $argName The argument name that is not implemented
26 */
27 public function __construct($methodName, $argName)
28 {
29 $message = sprintf('The %s() method\'s argument $%s behavior is not implemented.', $methodName, $argName);
30 parent::__construct($message);
31 }
32}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Exception/MethodArgumentValueNotImplementedException.php b/vendor/symfony/intl/Symfony/Component/Intl/Exception/MethodArgumentValueNotImplementedException.php
new file mode 100644
index 00000000..76e3f634
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Exception/MethodArgumentValueNotImplementedException.php
@@ -0,0 +1,41 @@
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\Exception;
13
14use Symfony\Component\Intl\Exception\NotImplementedException;
15
16/**
17 * @author Eriksen Costa <eriksen.costa@infranology.com.br>
18 */
19class MethodArgumentValueNotImplementedException extends NotImplementedException
20{
21 /**
22 * Constructor
23 *
24 * @param string $methodName The method name that raised the exception
25 * @param string $argName The argument name
26 * @param string $argValue The argument value that is not implemented
27 * @param string $additionalMessage An optional additional message to append to the exception message
28 */
29 public function __construct($methodName, $argName, $argValue, $additionalMessage = '')
30 {
31 $message = sprintf(
32 'The %s() method\'s argument $%s value %s behavior is not implemented.%s',
33 $methodName,
34 $argName,
35 var_export($argValue, true),
36 $additionalMessage !== '' ? ' '.$additionalMessage.'. ' : ''
37 );
38
39 parent::__construct($message);
40 }
41}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Exception/MethodNotImplementedException.php b/vendor/symfony/intl/Symfony/Component/Intl/Exception/MethodNotImplementedException.php
new file mode 100644
index 00000000..d8a0e90f
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Exception/MethodNotImplementedException.php
@@ -0,0 +1,28 @@
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\Exception;
13
14/**
15 * @author Eriksen Costa <eriksen.costa@infranology.com.br>
16 */
17class MethodNotImplementedException extends NotImplementedException
18{
19 /**
20 * Constructor
21 *
22 * @param string $methodName The name of the method
23 */
24 public function __construct($methodName)
25 {
26 parent::__construct(sprintf('The %s() is not implemented.', $methodName));
27 }
28}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Exception/NotImplementedException.php b/vendor/symfony/intl/Symfony/Component/Intl/Exception/NotImplementedException.php
new file mode 100644
index 00000000..1f3ba46b
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Exception/NotImplementedException.php
@@ -0,0 +1,32 @@
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\Exception;
13
14/**
15 * Base exception class for not implemented behaviors of the intl extension in the Locale component.
16 *
17 * @author Eriksen Costa <eriksen.costa@infranology.com.br>
18 */
19class NotImplementedException extends RuntimeException
20{
21 const INTL_INSTALL_MESSAGE = 'Please install the "intl" extension for full localization capabilities.';
22
23 /**
24 * Constructor
25 *
26 * @param string $message The exception message. A note to install the intl extension is appended to this string
27 */
28 public function __construct($message)
29 {
30 parent::__construct($message.' '.self::INTL_INSTALL_MESSAGE);
31 }
32}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Exception/OutOfBoundsException.php b/vendor/symfony/intl/Symfony/Component/Intl/Exception/OutOfBoundsException.php
new file mode 100644
index 00000000..2727141d
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Exception/OutOfBoundsException.php
@@ -0,0 +1,21 @@
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\Exception;
13
14/**
15 * Base OutOfBoundsException for the Intl component.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class OutOfBoundsException extends \OutOfBoundsException implements ExceptionInterface
20{
21}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Exception/RuntimeException.php b/vendor/symfony/intl/Symfony/Component/Intl/Exception/RuntimeException.php
new file mode 100644
index 00000000..98937142
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Exception/RuntimeException.php
@@ -0,0 +1,21 @@
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\Exception;
13
14/**
15 * RuntimeException for the Intl component.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class RuntimeException extends \RuntimeException implements ExceptionInterface
20{
21}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Globals/IntlGlobals.php b/vendor/symfony/intl/Symfony/Component/Intl/Globals/IntlGlobals.php
new file mode 100644
index 00000000..6da00011
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Globals/IntlGlobals.php
@@ -0,0 +1,137 @@
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\Globals;
13
14/**
15 * Provides fake static versions of the global functions in the intl extension
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19abstract class IntlGlobals
20{
21 /**
22 * Indicates that no error occurred
23 *
24 * @var integer
25 */
26 const U_ZERO_ERROR = 0;
27
28 /**
29 * Indicates that an invalid argument was passed
30 *
31 * @var integer
32 */
33 const U_ILLEGAL_ARGUMENT_ERROR = 1;
34
35 /**
36 * Indicates that the parse() operation failed
37 *
38 * @var integer
39 */
40 const U_PARSE_ERROR = 9;
41
42 /**
43 * All known error codes
44 *
45 * @var array
46 */
47 private static $errorCodes = array(
48 self::U_ZERO_ERROR => 'U_ZERO_ERROR',
49 self::U_ILLEGAL_ARGUMENT_ERROR => 'U_ILLEGAL_ARGUMENT_ERROR',
50 self::U_PARSE_ERROR => 'U_PARSE_ERROR',
51 );
52
53 /**
54 * The error code of the last operation
55 *
56 * @var integer
57 */
58 private static $errorCode = self::U_ZERO_ERROR;
59
60 /**
61 * The error code of the last operation
62 *
63 * @var integer
64 */
65 private static $errorMessage = 'U_ZERO_ERROR';
66
67 /**
68 * Returns whether the error code indicates a failure
69 *
70 * @param integer $errorCode The error code returned by IntlGlobals::getErrorCode()
71 *
72 * @return Boolean
73 */
74 public static function isFailure($errorCode)
75 {
76 return isset(self::$errorCodes[$errorCode])
77 && $errorCode > self::U_ZERO_ERROR;
78 }
79
80 /**
81 * Returns the error code of the last operation
82 *
83 * Returns IntlGlobals::U_ZERO_ERROR if no error occurred.
84 *
85 * @return integer
86 */
87 public static function getErrorCode()
88 {
89 return self::$errorCode;
90 }
91
92 /**
93 * Returns the error message of the last operation
94 *
95 * Returns "U_ZERO_ERROR" if no error occurred.
96 *
97 * @return string
98 */
99 public static function getErrorMessage()
100 {
101 return self::$errorMessage;
102 }
103
104 /**
105 * Returns the symbolic name for a given error code
106 *
107 * @param integer $code The error code returned by IntlGlobals::getErrorCode()
108 *
109 * @return string
110 */
111 public static function getErrorName($code)
112 {
113 if (isset(self::$errorCodes[$code])) {
114 return self::$errorCodes[$code];
115 }
116
117 return '[BOGUS UErrorCode]';
118 }
119
120 /**
121 * Sets the current error
122 *
123 * @param integer $code One of the error constants in this class
124 * @param string $message The ICU class error message
125 *
126 * @throws \InvalidArgumentException If the code is not one of the error constants in this class
127 */
128 public static function setError($code, $message = '')
129 {
130 if (!isset(self::$errorCodes[$code])) {
131 throw new \InvalidArgumentException(sprintf('No such error code: "%s"', $code));
132 }
133
134 self::$errorMessage = $message ? sprintf('%s: %s', $message, self::$errorCodes[$code]) : self::$errorCodes[$code];
135 self::$errorCode = $code;
136 }
137}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Intl.php b/vendor/symfony/intl/Symfony/Component/Intl/Intl.php
new file mode 100644
index 00000000..c13899a4
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Intl.php
@@ -0,0 +1,211 @@
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;
13
14use Symfony\Component\Icu\IcuCurrencyBundle;
15use Symfony\Component\Icu\IcuData;
16use Symfony\Component\Icu\IcuLanguageBundle;
17use Symfony\Component\Icu\IcuLocaleBundle;
18use Symfony\Component\Icu\IcuRegionBundle;
19use Symfony\Component\Intl\ResourceBundle\Reader\BufferedBundleReader;
20use Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReader;
21
22/**
23 * Gives access to internationalization data.
24 *
25 * @author Bernhard Schussek <bschussek@gmail.com>
26 */
27class Intl
28{
29 /**
30 * The number of resource bundles to buffer. Loading the same resource
31 * bundle for n locales takes up n spots in the buffer.
32 */
33 const BUFFER_SIZE = 10;
34
35 /**
36 * @var ResourceBundle\CurrencyBundleInterface
37 */
38 private static $currencyBundle;
39
40 /**
41 * @var ResourceBundle\LanguageBundleInterface
42 */
43 private static $languageBundle;
44
45 /**
46 * @var ResourceBundle\LocaleBundleInterface
47 */
48 private static $localeBundle;
49
50 /**
51 * @var ResourceBundle\RegionBundleInterface
52 */
53 private static $regionBundle;
54
55 /**
56 * @var string|Boolean|null
57 */
58 private static $icuVersion = false;
59
60 /**
61 * @var string
62 */
63 private static $icuDataVersion = false;
64
65 /**
66 * @var ResourceBundle\Reader\StructuredBundleReaderInterface
67 */
68 private static $bundleReader;
69
70 /**
71 * Returns whether the intl extension is installed.
72 *
73 * @return Boolean Returns true if the intl extension is installed, false otherwise.
74 */
75 public static function isExtensionLoaded()
76 {
77 return class_exists('\ResourceBundle');
78 }
79
80 /**
81 * Returns the bundle containing currency information.
82 *
83 * @return ResourceBundle\CurrencyBundleInterface The currency resource bundle.
84 */
85 public static function getCurrencyBundle()
86 {
87 if (null === self::$currencyBundle) {
88 self::$currencyBundle = new IcuCurrencyBundle(self::getBundleReader());
89 }
90
91 return self::$currencyBundle;
92 }
93
94 /**
95 * Returns the bundle containing language information.
96 *
97 * @return ResourceBundle\LanguageBundleInterface The language resource bundle.
98 */
99 public static function getLanguageBundle()
100 {
101 if (null === self::$languageBundle) {
102 self::$languageBundle = new IcuLanguageBundle(self::getBundleReader());
103 }
104
105 return self::$languageBundle;
106 }
107
108 /**
109 * Returns the bundle containing locale information.
110 *
111 * @return ResourceBundle\LocaleBundleInterface The locale resource bundle.
112 */
113 public static function getLocaleBundle()
114 {
115 if (null === self::$localeBundle) {
116 self::$localeBundle = new IcuLocaleBundle(self::getBundleReader());
117 }
118
119 return self::$localeBundle;
120 }
121
122 /**
123 * Returns the bundle containing region information.
124 *
125 * @return ResourceBundle\RegionBundleInterface The region resource bundle.
126 */
127 public static function getRegionBundle()
128 {
129 if (null === self::$regionBundle) {
130 self::$regionBundle = new IcuRegionBundle(self::getBundleReader());
131 }
132
133 return self::$regionBundle;
134 }
135
136 /**
137 * Returns the version of the installed ICU library.
138 *
139 * @return null|string The ICU version or NULL if it could not be determined.
140 */
141 public static function getIcuVersion()
142 {
143 if (false === self::$icuVersion) {
144 if (!self::isExtensionLoaded()) {
145 self::$icuVersion = self::getIcuStubVersion();
146 } elseif (defined('INTL_ICU_VERSION')) {
147 self::$icuVersion = INTL_ICU_VERSION;
148 } else {
149 try {
150 $reflector = new \ReflectionExtension('intl');
151 ob_start();
152 $reflector->info();
153 $output = strip_tags(ob_get_clean());
154 preg_match('/^ICU version (?:=>)?(.*)$/m', $output, $matches);
155
156 self::$icuVersion = trim($matches[1]);
157 } catch (\ReflectionException $e) {
158 self::$icuVersion = null;
159 }
160 }
161 }
162
163 return self::$icuVersion;
164 }
165
166 /**
167 * Returns the version of the installed ICU data.
168 *
169 * @return string The version of the installed ICU data.
170 */
171 public static function getIcuDataVersion()
172 {
173 if (false === self::$icuDataVersion) {
174 self::$icuDataVersion = IcuData::getVersion();
175 }
176
177 return self::$icuDataVersion;
178 }
179
180 /**
181 * Returns the ICU version that the stub classes mimic.
182 *
183 * @return string The ICU version of the stub classes.
184 */
185 public static function getIcuStubVersion()
186 {
187 return '50.1.2';
188 }
189
190 /**
191 * Returns a resource bundle reader for .php resource bundle files.
192 *
193 * @return ResourceBundle\Reader\StructuredBundleReaderInterface The resource reader.
194 */
195 private static function getBundleReader()
196 {
197 if (null === self::$bundleReader) {
198 self::$bundleReader = new StructuredBundleReader(new BufferedBundleReader(
199 IcuData::getBundleReader(),
200 self::BUFFER_SIZE
201 ));
202 }
203
204 return self::$bundleReader;
205 }
206
207 /**
208 * This class must not be instantiated.
209 */
210 private function __construct() {}
211}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/LICENSE b/vendor/symfony/intl/Symfony/Component/Intl/LICENSE
new file mode 100644
index 00000000..88a57f8d
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/LICENSE
@@ -0,0 +1,19 @@
1Copyright (c) 2004-2013 Fabien Potencier
2
3Permission is hereby granted, free of charge, to any person obtaining a copy
4of this software and associated documentation files (the "Software"), to deal
5in the Software without restriction, including without limitation the rights
6to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7copies of the Software, and to permit persons to whom the Software is furnished
8to do so, subject to the following conditions:
9
10The above copyright notice and this permission notice shall be included in all
11copies or substantial portions of the Software.
12
13THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19THE SOFTWARE.
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Locale/Locale.php b/vendor/symfony/intl/Symfony/Component/Intl/Locale/Locale.php
new file mode 100644
index 00000000..cca4e9e4
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Locale/Locale.php
@@ -0,0 +1,317 @@
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\Locale;
13
14use Symfony\Component\Intl\Exception\MethodNotImplementedException;
15
16/**
17 * Replacement for PHP's native {@link \Locale} class.
18 *
19 * The only method supported in this class is {@link getDefault}. This method
20 * will always return "en". All other methods will throw an exception when used.
21 *
22 * @author Eriksen Costa <eriksen.costa@infranology.com.br>
23 * @author Bernhard Schussek <bschussek@gmail.com>
24 */
25class Locale
26{
27 const DEFAULT_LOCALE = null;
28
29 /* Locale method constants */
30 const ACTUAL_LOCALE = 0;
31 const VALID_LOCALE = 1;
32
33 /* Language tags constants */
34 const LANG_TAG = 'language';
35 const EXTLANG_TAG = 'extlang';
36 const SCRIPT_TAG = 'script';
37 const REGION_TAG = 'region';
38 const VARIANT_TAG = 'variant';
39 const GRANDFATHERED_LANG_TAG = 'grandfathered';
40 const PRIVATE_TAG = 'private';
41
42 /**
43 * Not supported. Returns the best available locale based on HTTP "Accept-Language" header according to RFC 2616
44 *
45 * @param string $header The string containing the "Accept-Language" header value
46 *
47 * @return string The corresponding locale code
48 *
49 * @see http://www.php.net/manual/en/locale.acceptfromhttp.php
50 *
51 * @throws MethodNotImplementedException
52 */
53 public static function acceptFromHttp($header)
54 {
55 throw new MethodNotImplementedException(__METHOD__);
56 }
57
58 /**
59 * Not supported. Returns a correctly ordered and delimited locale code
60 *
61 * @param array $subtags A keyed array where the keys identify the particular locale code subtag
62 *
63 * @return string The corresponding locale code
64 *
65 * @see http://www.php.net/manual/en/locale.composelocale.php
66 *
67 * @throws MethodNotImplementedException
68 */
69 public static function composeLocale(array $subtags)
70 {
71 throw new MethodNotImplementedException(__METHOD__);
72 }
73
74 /**
75 * Not supported. Checks if a language tag filter matches with locale
76 *
77 * @param string $langtag The language tag to check
78 * @param string $locale The language range to check against
79 * @param Boolean $canonicalize
80 *
81 * @return string The corresponding locale code
82 *
83 * @see http://www.php.net/manual/en/locale.filtermatches.php
84 *
85 * @throws MethodNotImplementedException
86 */
87 public static function filterMatches($langtag, $locale, $canonicalize = false)
88 {
89 throw new MethodNotImplementedException(__METHOD__);
90 }
91
92 /**
93 * Not supported. Returns the variants for the input locale
94 *
95 * @param string $locale The locale to extract the variants from
96 *
97 * @return array The locale variants
98 *
99 * @see http://www.php.net/manual/en/locale.getallvariants.php
100 *
101 * @throws MethodNotImplementedException
102 */
103 public static function getAllVariants($locale)
104 {
105 throw new MethodNotImplementedException(__METHOD__);
106 }
107
108 /**
109 * Returns the default locale
110 *
111 * @return string The default locale code. Always returns 'en'
112 *
113 * @see http://www.php.net/manual/en/locale.getdefault.php
114 */
115 public static function getDefault()
116 {
117 return 'en';
118 }
119
120 /**
121 * Not supported. Returns the localized display name for the locale language
122 *
123 * @param string $locale The locale code to return the display language from
124 * @param string $inLocale Optional format locale code to use to display the language name
125 *
126 * @return string The localized language display name
127 *
128 * @see http://www.php.net/manual/en/locale.getdisplaylanguage.php
129 *
130 * @throws MethodNotImplementedException
131 */
132 public static function getDisplayLanguage($locale, $inLocale = null)
133 {
134 throw new MethodNotImplementedException(__METHOD__);
135 }
136
137 /**
138 * Not supported. Returns the localized display name for the locale
139 *
140 * @param string $locale The locale code to return the display locale name from
141 * @param string $inLocale Optional format locale code to use to display the locale name
142 *
143 * @return string The localized locale display name
144 *
145 * @see http://www.php.net/manual/en/locale.getdisplayname.php
146 *
147 * @throws MethodNotImplementedException
148 */
149 public static function getDisplayName($locale, $inLocale = null)
150 {
151 throw new MethodNotImplementedException(__METHOD__);
152 }
153
154 /**
155 * Not supported. Returns the localized display name for the locale region
156 *
157 * @param string $locale The locale code to return the display region from
158 * @param string $inLocale Optional format locale code to use to display the region name
159 *
160 * @return string The localized region display name
161 *
162 * @see http://www.php.net/manual/en/locale.getdisplayregion.php
163 *
164 * @throws MethodNotImplementedException
165 */
166 public static function getDisplayRegion($locale, $inLocale = null)
167 {
168 throw new MethodNotImplementedException(__METHOD__);
169 }
170
171 /**
172 * Not supported. Returns the localized display name for the locale script
173 *
174 * @param string $locale The locale code to return the display script from
175 * @param string $inLocale Optional format locale code to use to display the script name
176 *
177 * @return string The localized script display name
178 *
179 * @see http://www.php.net/manual/en/locale.getdisplayscript.php
180 *
181 * @throws MethodNotImplementedException
182 */
183 public static function getDisplayScript($locale, $inLocale = null)
184 {
185 throw new MethodNotImplementedException(__METHOD__);
186 }
187
188 /**
189 * Not supported. Returns the localized display name for the locale variant
190 *
191 * @param string $locale The locale code to return the display variant from
192 * @param string $inLocale Optional format locale code to use to display the variant name
193 *
194 * @return string The localized variant display name
195 *
196 * @see http://www.php.net/manual/en/locale.getdisplayvariant.php
197 *
198 * @throws MethodNotImplementedException
199 */
200 public static function getDisplayVariant($locale, $inLocale = null)
201 {
202 throw new MethodNotImplementedException(__METHOD__);
203 }
204
205 /**
206 * Not supported. Returns the keywords for the locale
207 *
208 * @param string $locale The locale code to extract the keywords from
209 *
210 * @return array Associative array with the extracted variants
211 *
212 * @see http://www.php.net/manual/en/locale.getkeywords.php
213 *
214 * @throws MethodNotImplementedException
215 */
216 public static function getKeywords($locale)
217 {
218 throw new MethodNotImplementedException(__METHOD__);
219 }
220
221 /**
222 * Not supported. Returns the primary language for the locale
223 *
224 * @param string $locale The locale code to extract the language code from
225 *
226 * @return string|null The extracted language code or null in case of error
227 *
228 * @see http://www.php.net/manual/en/locale.getprimarylanguage.php
229 *
230 * @throws MethodNotImplementedException
231 */
232 public static function getPrimaryLanguage($locale)
233 {
234 throw new MethodNotImplementedException(__METHOD__);
235 }
236
237 /**
238 * Not supported. Returns the region for the locale
239 *
240 * @param string $locale The locale code to extract the region code from
241 *
242 * @return string|null The extracted region code or null if not present
243 *
244 * @see http://www.php.net/manual/en/locale.getregion.php
245 *
246 * @throws MethodNotImplementedException
247 */
248 public static function getRegion($locale)
249 {
250 throw new MethodNotImplementedException(__METHOD__);
251 }
252
253 /**
254 * Not supported. Returns the script for the locale
255 *
256 * @param string $locale The locale code to extract the script code from
257 *
258 * @return string|null The extracted script code or null if not present
259 *
260 * @see http://www.php.net/manual/en/locale.getscript.php
261 *
262 * @throws MethodNotImplementedException
263 */
264 public static function getScript($locale)
265 {
266 throw new MethodNotImplementedException(__METHOD__);
267 }
268
269 /**
270 * Not supported. Returns the closest language tag for the locale
271 *
272 * @param array $langtag A list of the language tags to compare to locale
273 * @param string $locale The locale to use as the language range when matching
274 * @param Boolean $canonicalize If true, the arguments will be converted to canonical form before matching
275 * @param string $default The locale to use if no match is found
276 *
277 * @see http://www.php.net/manual/en/locale.lookup.php
278 *
279 * @throws MethodNotImplementedException
280 */
281 public static function lookup(array $langtag, $locale, $canonicalize = false, $default = null)
282 {
283 throw new MethodNotImplementedException(__METHOD__);
284 }
285
286 /**
287 * Not supported. Returns an associative array of locale identifier subtags
288 *
289 * @param string $locale The locale code to extract the subtag array from
290 *
291 * @return array Associative array with the extracted subtags
292 *
293 * @see http://www.php.net/manual/en/locale.parselocale.php
294 *
295 * @throws MethodNotImplementedException
296 */
297 public static function parseLocale($locale)
298 {
299 throw new MethodNotImplementedException(__METHOD__);
300 }
301
302 /**
303 * Not supported. Sets the default runtime locale
304 *
305 * @param string $locale The locale code
306 *
307 * @return Boolean true on success or false on failure
308 *
309 * @see http://www.php.net/manual/en/locale.parselocale.php
310 *
311 * @throws MethodNotImplementedException
312 */
313 public static function setDefault($locale)
314 {
315 throw new MethodNotImplementedException(__METHOD__);
316 }
317}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php b/vendor/symfony/intl/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php
new file mode 100644
index 00000000..0e5652e2
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php
@@ -0,0 +1,891 @@
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\NumberFormatter;
13
14use Symfony\Component\Intl\Exception\NotImplementedException;
15use Symfony\Component\Intl\Exception\MethodNotImplementedException;
16use Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException;
17use Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException;
18use Symfony\Component\Intl\Globals\IntlGlobals;
19use Symfony\Component\Intl\Intl;
20use Symfony\Component\Intl\Locale\Locale;
21
22/**
23 * Replacement for PHP's native {@link \NumberFormatter} class.
24 *
25 * The only methods currently supported in this class are:
26 *
27 * - {@link __construct}
28 * - {@link create}
29 * - {@link formatCurrency}
30 * - {@link format}
31 * - {@link getAttribute}
32 * - {@link getErrorCode}
33 * - {@link getErrorMessage}
34 * - {@link getLocale}
35 * - {@link parse}
36 * - {@link setAttribute}
37 *
38 * @author Eriksen Costa <eriksen.costa@infranology.com.br>
39 * @author Bernhard Schussek <bschussek@gmail.com>
40 */
41class NumberFormatter
42{
43 /* Format style constants */
44 const PATTERN_DECIMAL = 0;
45 const DECIMAL = 1;
46 const CURRENCY = 2;
47 const PERCENT = 3;
48 const SCIENTIFIC = 4;
49 const SPELLOUT = 5;
50 const ORDINAL = 6;
51 const DURATION = 7;
52 const PATTERN_RULEBASED = 9;
53 const IGNORE = 0;
54 const DEFAULT_STYLE = 1;
55
56 /* Format type constants */
57 const TYPE_DEFAULT = 0;
58 const TYPE_INT32 = 1;
59 const TYPE_INT64 = 2;
60 const TYPE_DOUBLE = 3;
61 const TYPE_CURRENCY = 4;
62
63 /* Numeric attribute constants */
64 const PARSE_INT_ONLY = 0;
65 const GROUPING_USED = 1;
66 const DECIMAL_ALWAYS_SHOWN = 2;
67 const MAX_INTEGER_DIGITS = 3;
68 const MIN_INTEGER_DIGITS = 4;
69 const INTEGER_DIGITS = 5;
70 const MAX_FRACTION_DIGITS = 6;
71 const MIN_FRACTION_DIGITS = 7;
72 const FRACTION_DIGITS = 8;
73 const MULTIPLIER = 9;
74 const GROUPING_SIZE = 10;
75 const ROUNDING_MODE = 11;
76 const ROUNDING_INCREMENT = 12;
77 const FORMAT_WIDTH = 13;
78 const PADDING_POSITION = 14;
79 const SECONDARY_GROUPING_SIZE = 15;
80 const SIGNIFICANT_DIGITS_USED = 16;
81 const MIN_SIGNIFICANT_DIGITS = 17;
82 const MAX_SIGNIFICANT_DIGITS = 18;
83 const LENIENT_PARSE = 19;
84
85 /* Text attribute constants */
86 const POSITIVE_PREFIX = 0;
87 const POSITIVE_SUFFIX = 1;
88 const NEGATIVE_PREFIX = 2;
89 const NEGATIVE_SUFFIX = 3;
90 const PADDING_CHARACTER = 4;
91 const CURRENCY_CODE = 5;
92 const DEFAULT_RULESET = 6;
93 const PUBLIC_RULESETS = 7;
94
95 /* Format symbol constants */
96 const DECIMAL_SEPARATOR_SYMBOL = 0;
97 const GROUPING_SEPARATOR_SYMBOL = 1;
98 const PATTERN_SEPARATOR_SYMBOL = 2;
99 const PERCENT_SYMBOL = 3;
100 const ZERO_DIGIT_SYMBOL = 4;
101 const DIGIT_SYMBOL = 5;
102 const MINUS_SIGN_SYMBOL = 6;
103 const PLUS_SIGN_SYMBOL = 7;
104 const CURRENCY_SYMBOL = 8;
105 const INTL_CURRENCY_SYMBOL = 9;
106 const MONETARY_SEPARATOR_SYMBOL = 10;
107 const EXPONENTIAL_SYMBOL = 11;
108 const PERMILL_SYMBOL = 12;
109 const PAD_ESCAPE_SYMBOL = 13;
110 const INFINITY_SYMBOL = 14;
111 const NAN_SYMBOL = 15;
112 const SIGNIFICANT_DIGIT_SYMBOL = 16;
113 const MONETARY_GROUPING_SEPARATOR_SYMBOL = 17;
114
115 /* Rounding mode values used by NumberFormatter::setAttribute() with NumberFormatter::ROUNDING_MODE attribute */
116 const ROUND_CEILING = 0;
117 const ROUND_FLOOR = 1;
118 const ROUND_DOWN = 2;
119 const ROUND_UP = 3;
120 const ROUND_HALFEVEN = 4;
121 const ROUND_HALFDOWN = 5;
122 const ROUND_HALFUP = 6;
123
124 /* Pad position values used by NumberFormatter::setAttribute() with NumberFormatter::PADDING_POSITION attribute */
125 const PAD_BEFORE_PREFIX = 0;
126 const PAD_AFTER_PREFIX = 1;
127 const PAD_BEFORE_SUFFIX = 2;
128 const PAD_AFTER_SUFFIX = 3;
129
130 /**
131 * The error code from the last operation
132 *
133 * @var integer
134 */
135 protected $errorCode = IntlGlobals::U_ZERO_ERROR;
136
137 /**
138 * The error message from the last operation
139 *
140 * @var string
141 */
142 protected $errorMessage = 'U_ZERO_ERROR';
143
144 /**
145 * @var int
146 */
147 private $style;
148
149 /**
150 * Default values for the en locale
151 *
152 * @var array
153 */
154 private $attributes = array(
155 self::FRACTION_DIGITS => 0,
156 self::GROUPING_USED => 1,
157 self::ROUNDING_MODE => self::ROUND_HALFEVEN
158 );
159
160 /**
161 * Holds the initialized attributes code
162 *
163 * @var array
164 */
165 private $initializedAttributes = array();
166
167 /**
168 * The supported styles to the constructor $styles argument
169 *
170 * @var array
171 */
172 private static $supportedStyles = array(
173 'CURRENCY' => self::CURRENCY,
174 'DECIMAL' => self::DECIMAL
175 );
176
177 /**
178 * Supported attributes to the setAttribute() $attr argument
179 *
180 * @var array
181 */
182 private static $supportedAttributes = array(
183 'FRACTION_DIGITS' => self::FRACTION_DIGITS,
184 'GROUPING_USED' => self::GROUPING_USED,
185 'ROUNDING_MODE' => self::ROUNDING_MODE
186 );
187
188 /**
189 * The available rounding modes for setAttribute() usage with
190 * NumberFormatter::ROUNDING_MODE. NumberFormatter::ROUND_DOWN
191 * and NumberFormatter::ROUND_UP does not have a PHP only equivalent
192 *
193 * @var array
194 */
195 private static $roundingModes = array(
196 'ROUND_HALFEVEN' => self::ROUND_HALFEVEN,
197 'ROUND_HALFDOWN' => self::ROUND_HALFDOWN,
198 'ROUND_HALFUP' => self::ROUND_HALFUP
199 );
200
201 /**
202 * The mapping between NumberFormatter rounding modes to the available
203 * modes in PHP's round() function.
204 *
205 * @see http://www.php.net/manual/en/function.round.php
206 *
207 * @var array
208 */
209 private static $phpRoundingMap = array(
210 self::ROUND_HALFDOWN => \PHP_ROUND_HALF_DOWN,
211 self::ROUND_HALFEVEN => \PHP_ROUND_HALF_EVEN,
212 self::ROUND_HALFUP => \PHP_ROUND_HALF_UP
213 );
214
215 /**
216 * The maximum values of the integer type in 32 bit platforms.
217 *
218 * @var array
219 */
220 private static $int32Range = array(
221 'positive' => 2147483647,
222 'negative' => -2147483648
223 );
224
225 /**
226 * The maximum values of the integer type in 64 bit platforms.
227 *
228 * @var array
229 */
230 private static $int64Range = array(
231 'positive' => 9223372036854775807,
232 'negative' => -9223372036854775808
233 );
234
235 /**
236 * Constructor.
237 *
238 * @param string $locale The locale code. The only currently supported locale is "en".
239 * @param int $style Style of the formatting, one of the format style constants.
240 * The only supported styles are NumberFormatter::DECIMAL
241 * and NumberFormatter::CURRENCY.
242 * @param string $pattern Not supported. A pattern string in case $style is NumberFormat::PATTERN_DECIMAL or
243 * NumberFormat::PATTERN_RULEBASED. It must conform to the syntax
244 * described in the ICU DecimalFormat or ICU RuleBasedNumberFormat documentation
245 *
246 * @see http://www.php.net/manual/en/numberformatter.create.php
247 * @see http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details
248 * @see http://www.icu-project.org/apiref/icu4c/classRuleBasedNumberFormat.html#_details
249 *
250 * @throws MethodArgumentValueNotImplementedException When $locale different than "en" is passed
251 * @throws MethodArgumentValueNotImplementedException When the $style is not supported
252 * @throws MethodArgumentNotImplementedException When the pattern value is different than null
253 */
254 public function __construct($locale = 'en', $style = null, $pattern = null)
255 {
256 if ('en' != $locale) {
257 throw new MethodArgumentValueNotImplementedException(__METHOD__, 'locale', $locale, 'Only the locale "en" is supported');
258 }
259
260 if (!in_array($style, self::$supportedStyles)) {
261 $message = sprintf('The available styles are: %s.', implode(', ', array_keys(self::$supportedStyles)));
262 throw new MethodArgumentValueNotImplementedException(__METHOD__, 'style', $style, $message);
263 }
264
265 if (null !== $pattern) {
266 throw new MethodArgumentNotImplementedException(__METHOD__, 'pattern');
267 }
268
269 $this->style = $style;
270 }
271
272 /**
273 * Static constructor.
274 *
275 * @param string $locale The locale code. The only supported locale is "en".
276 * @param int $style Style of the formatting, one of the format style constants.
277 * The only currently supported styles are NumberFormatter::DECIMAL
278 * and NumberFormatter::CURRENCY.
279 * @param string $pattern Not supported. A pattern string in case $style is NumberFormat::PATTERN_DECIMAL or
280 * NumberFormat::PATTERN_RULEBASED. It must conform to the syntax
281 * described in the ICU DecimalFormat or ICU RuleBasedNumberFormat documentation
282 *
283 * @return NumberFormatter
284 *
285 * @see http://www.php.net/manual/en/numberformatter.create.php
286 * @see http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details
287 * @see http://www.icu-project.org/apiref/icu4c/classRuleBasedNumberFormat.html#_details
288 *
289 * @throws MethodArgumentValueNotImplementedException When $locale different than "en" is passed
290 * @throws MethodArgumentValueNotImplementedException When the $style is not supported
291 * @throws MethodArgumentNotImplementedException When the pattern value is different than null
292 */
293 public static function create($locale = 'en', $style = null, $pattern = null)
294 {
295 return new self($locale, $style, $pattern);
296 }
297
298 /**
299 * Format a currency value
300 *
301 * @param float $value The numeric currency value
302 * @param string $currency The 3-letter ISO 4217 currency code indicating the currency to use
303 *
304 * @return string The formatted currency value
305 *
306 * @see http://www.php.net/manual/en/numberformatter.formatcurrency.php
307 * @see http://www.iso.org/iso/support/faqs/faqs_widely_used_standards/widely_used_standards_other/currency_codes/currency_codes_list-1.htm
308 */
309 public function formatCurrency($value, $currency)
310 {
311 if ($this->style == self::DECIMAL) {
312 return $this->format($value);
313 }
314
315 $symbol = Intl::getCurrencyBundle()->getCurrencySymbol($currency, 'en');
316 $fractionDigits = Intl::getCurrencyBundle()->getFractionDigits($currency);
317
318 $value = $this->roundCurrency($value, $currency);
319
320 $negative = false;
321 if (0 > $value) {
322 $negative = true;
323 $value *= -1;
324 }
325
326 $value = $this->formatNumber($value, $fractionDigits);
327
328 $ret = $symbol.$value;
329
330 return $negative ? '('.$ret.')' : $ret;
331 }
332
333 /**
334 * Format a number
335 *
336 * @param number $value The value to format
337 * @param int $type Type of the formatting, one of the format type constants.
338 * Only type NumberFormatter::TYPE_DEFAULT is currently supported.
339 *
340 * @return Boolean|string The formatted value or false on error
341 *
342 * @see http://www.php.net/manual/en/numberformatter.format.php
343 *
344 * @throws NotImplementedException If the method is called with the class $style 'CURRENCY'
345 * @throws MethodArgumentValueNotImplementedException If the $type is different than TYPE_DEFAULT
346 */
347 public function format($value, $type = self::TYPE_DEFAULT)
348 {
349 // The original NumberFormatter does not support this format type
350 if ($type == self::TYPE_CURRENCY) {
351 trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING);
352
353 return false;
354 }
355
356 if ($this->style == self::CURRENCY) {
357 throw new NotImplementedException(sprintf(
358 '%s() method does not support the formatting of currencies (instance with CURRENCY style). %s',
359 __METHOD__, NotImplementedException::INTL_INSTALL_MESSAGE
360 ));
361 }
362
363 // Only the default type is supported.
364 if ($type != self::TYPE_DEFAULT) {
365 throw new MethodArgumentValueNotImplementedException(__METHOD__, 'type', $type, 'Only TYPE_DEFAULT is supported');
366 }
367
368 $fractionDigits = $this->getAttribute(self::FRACTION_DIGITS);
369
370 $value = $this->round($value, $fractionDigits);
371 $value = $this->formatNumber($value, $fractionDigits);
372
373 // behave like the intl extension
374 $this->resetError();
375
376 return $value;
377 }
378
379 /**
380 * Returns an attribute value
381 *
382 * @param int $attr An attribute specifier, one of the numeric attribute constants
383 *
384 * @return Boolean|int The attribute value on success or false on error
385 *
386 * @see http://www.php.net/manual/en/numberformatter.getattribute.php
387 */
388 public function getAttribute($attr)
389 {
390 return isset($this->attributes[$attr]) ? $this->attributes[$attr] : null;
391 }
392
393 /**
394 * Returns formatter's last error code. Always returns the U_ZERO_ERROR class constant value
395 *
396 * @return int The error code from last formatter call
397 *
398 * @see http://www.php.net/manual/en/numberformatter.geterrorcode.php
399 */
400 public function getErrorCode()
401 {
402 return $this->errorCode;
403 }
404
405 /**
406 * Returns formatter's last error message. Always returns the U_ZERO_ERROR_MESSAGE class constant value
407 *
408 * @return string The error message from last formatter call
409 *
410 * @see http://www.php.net/manual/en/numberformatter.geterrormessage.php
411 */
412 public function getErrorMessage()
413 {
414 return $this->errorMessage;
415 }
416
417 /**
418 * Returns the formatter's locale
419 *
420 * The parameter $type is currently ignored.
421 *
422 * @param int $type Not supported. The locale name type to return (Locale::VALID_LOCALE or Locale::ACTUAL_LOCALE)
423 *
424 * @return string The locale used to create the formatter. Currently always
425 * returns "en".
426 *
427 * @see http://www.php.net/manual/en/numberformatter.getlocale.php
428 */
429 public function getLocale($type = Locale::ACTUAL_LOCALE)
430 {
431 return 'en';
432 }
433
434 /**
435 * Not supported. Returns the formatter's pattern
436 *
437 * @return Boolean|string The pattern string used by the formatter or false on error
438 *
439 * @see http://www.php.net/manual/en/numberformatter.getpattern.php
440 *
441 * @throws MethodNotImplementedException
442 */
443 public function getPattern()
444 {
445 throw new MethodNotImplementedException(__METHOD__);
446 }
447
448 /**
449 * Not supported. Returns a formatter symbol value
450 *
451 * @param int $attr A symbol specifier, one of the format symbol constants
452 *
453 * @return Boolean|string The symbol value or false on error
454 *
455 * @see http://www.php.net/manual/en/numberformatter.getsymbol.php
456 *
457 * @throws MethodNotImplementedException
458 */
459 public function getSymbol($attr)
460 {
461 throw new MethodNotImplementedException(__METHOD__);
462 }
463
464 /**
465 * Not supported. Returns a formatter text attribute value
466 *
467 * @param int $attr An attribute specifier, one of the text attribute constants
468 *
469 * @return Boolean|string The attribute value or false on error
470 *
471 * @see http://www.php.net/manual/en/numberformatter.gettextattribute.php
472 *
473 * @throws MethodNotImplementedException
474 */
475 public function getTextAttribute($attr)
476 {
477 throw new MethodNotImplementedException(__METHOD__);
478 }
479
480 /**
481 * Not supported. Parse a currency number
482 *
483 * @param string $value The value to parse
484 * @param string $currency Parameter to receive the currency name (reference)
485 * @param int $position Offset to begin the parsing on return this value will hold the offset at which the parsing ended
486 *
487 * @return Boolean|string The parsed numeric value of false on error
488 *
489 * @see http://www.php.net/manual/en/numberformatter.parsecurrency.php
490 *
491 * @throws MethodNotImplementedException
492 */
493 public function parseCurrency($value, &$currency, &$position = null)
494 {
495 throw new MethodNotImplementedException(__METHOD__);
496 }
497
498 /**
499 * Parse a number
500 *
501 * @param string $value The value to parse
502 * @param int $type Type of the formatting, one of the format type constants.
503 * The only currently supported types are NumberFormatter::TYPE_DOUBLE,
504 * NumberFormatter::TYPE_INT32 and NumberFormatter::TYPE_INT64.
505 * @param int $position Not supported. Offset to begin the parsing on return this value will hold the offset at which the parsing ended
506 *
507 * @return Boolean|string The parsed value of false on error
508 *
509 * @see http://www.php.net/manual/en/numberformatter.parse.php
510 *
511 * @throws MethodArgumentNotImplementedException When $position different than null, behavior not implemented
512 */
513 public function parse($value, $type = self::TYPE_DOUBLE, &$position = null)
514 {
515 if ($type == self::TYPE_DEFAULT || $type == self::TYPE_CURRENCY) {
516 trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING);
517
518 return false;
519 }
520
521 // We don't calculate the position when parsing the value
522 if (null !== $position) {
523 throw new MethodArgumentNotImplementedException(__METHOD__, 'position');
524 }
525
526 preg_match('/^([^0-9\-]{0,})(.*)/', $value, $matches);
527
528 // Any string before the numeric value causes error in the parsing
529 if (isset($matches[1]) && !empty($matches[1])) {
530 IntlGlobals::setError(IntlGlobals::U_PARSE_ERROR, 'Number parsing failed');
531 $this->errorCode = IntlGlobals::getErrorCode();
532 $this->errorMessage = IntlGlobals::getErrorMessage();
533
534 return false;
535 }
536
537 // Remove everything that is not number or dot (.)
538 $value = preg_replace('/[^0-9\.\-]/', '', $value);
539 $value = $this->convertValueDataType($value, $type);
540
541 // behave like the intl extension
542 $this->resetError();
543
544 return $value;
545 }
546
547 /**
548 * Set an attribute
549 *
550 * @param int $attr An attribute specifier, one of the numeric attribute constants.
551 * The only currently supported attributes are NumberFormatter::FRACTION_DIGITS,
552 * NumberFormatter::GROUPING_USED and NumberFormatter::ROUNDING_MODE.
553 * @param int $value The attribute value. The only currently supported rounding modes are
554 * NumberFormatter::ROUND_HALFEVEN, NumberFormatter::ROUND_HALFDOWN and
555 * NumberFormatter::ROUND_HALFUP.
556 *
557 * @return Boolean true on success or false on failure
558 *
559 * @see http://www.php.net/manual/en/numberformatter.setattribute.php
560 *
561 * @throws MethodArgumentValueNotImplementedException When the $attr is not supported
562 * @throws MethodArgumentValueNotImplementedException When the $value is not supported
563 */
564 public function setAttribute($attr, $value)
565 {
566 if (!in_array($attr, self::$supportedAttributes)) {
567 $message = sprintf(
568 'The available attributes are: %s',
569 implode(', ', array_keys(self::$supportedAttributes))
570 );
571
572 throw new MethodArgumentValueNotImplementedException(__METHOD__, 'attr', $value, $message);
573 }
574
575 if (self::$supportedAttributes['ROUNDING_MODE'] == $attr && $this->isInvalidRoundingMode($value)) {
576 $message = sprintf(
577 'The supported values for ROUNDING_MODE are: %s',
578 implode(', ', array_keys(self::$roundingModes))
579 );
580
581 throw new MethodArgumentValueNotImplementedException(__METHOD__, 'attr', $value, $message);
582 }
583
584 if (self::$supportedAttributes['GROUPING_USED'] == $attr) {
585 $value = $this->normalizeGroupingUsedValue($value);
586 }
587
588 if (self::$supportedAttributes['FRACTION_DIGITS'] == $attr) {
589 $value = $this->normalizeFractionDigitsValue($value);
590 }
591
592 $this->attributes[$attr] = $value;
593 $this->initializedAttributes[$attr] = true;
594
595 return true;
596 }
597
598 /**
599 * Not supported. Set the formatter's pattern
600 *
601 * @param string $pattern A pattern string in conformance with the ICU DecimalFormat documentation
602 *
603 * @return Boolean true on success or false on failure
604 *
605 * @see http://www.php.net/manual/en/numberformatter.setpattern.php
606 * @see http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details
607 *
608 * @throws MethodNotImplementedException
609 */
610 public function setPattern($pattern)
611 {
612 throw new MethodNotImplementedException(__METHOD__);
613 }
614
615 /**
616 * Not supported. Set the formatter's symbol
617 *
618 * @param int $attr A symbol specifier, one of the format symbol constants
619 * @param string $value The value for the symbol
620 *
621 * @return Boolean true on success or false on failure
622 *
623 * @see http://www.php.net/manual/en/numberformatter.setsymbol.php
624 *
625 * @throws MethodNotImplementedException
626 */
627 public function setSymbol($attr, $value)
628 {
629 throw new MethodNotImplementedException(__METHOD__);
630 }
631
632 /**
633 * Not supported. Set a text attribute
634 *
635 * @param int $attr An attribute specifier, one of the text attribute constants
636 * @param int $value The attribute value
637 *
638 * @return Boolean true on success or false on failure
639 *
640 * @see http://www.php.net/manual/en/numberformatter.settextattribute.php
641 *
642 * @throws MethodNotImplementedException
643 */
644 public function setTextAttribute($attr, $value)
645 {
646 throw new MethodNotImplementedException(__METHOD__);
647 }
648
649 /**
650 * Set the error to the default U_ZERO_ERROR
651 */
652 protected function resetError()
653 {
654 IntlGlobals::setError(IntlGlobals::U_ZERO_ERROR);
655 $this->errorCode = IntlGlobals::getErrorCode();
656 $this->errorMessage = IntlGlobals::getErrorMessage();
657 }
658
659 /**
660 * Rounds a currency value, applying increment rounding if applicable
661 *
662 * When a currency have a rounding increment, an extra round is made after the first one. The rounding factor is
663 * determined in the ICU data and is explained as of:
664 *
665 * "the rounding increment is given in units of 10^(-fraction_digits)"
666 *
667 * The only actual rounding data as of this writing, is CHF.
668 *
669 * @param float $value The numeric currency value
670 * @param string $currency The 3-letter ISO 4217 currency code indicating the currency to use
671 *
672 * @return string The rounded numeric currency value
673 *
674 * @see http://en.wikipedia.org/wiki/Swedish_rounding
675 * @see http://www.docjar.com/html/api/com/ibm/icu/util/Currency.java.html#1007
676 */
677 private function roundCurrency($value, $currency)
678 {
679 $fractionDigits = Intl::getCurrencyBundle()->getFractionDigits($currency);
680 $roundingIncrement = Intl::getCurrencyBundle()->getRoundingIncrement($currency);
681
682 // Round with the formatter rounding mode
683 $value = $this->round($value, $fractionDigits);
684
685 // Swiss rounding
686 if (0 < $roundingIncrement && 0 < $fractionDigits) {
687 $roundingFactor = $roundingIncrement / pow(10, $fractionDigits);
688 $value = round($value / $roundingFactor) * $roundingFactor;
689 }
690
691 return $value;
692 }
693
694 /**
695 * Rounds a value.
696 *
697 * @param integer|float $value The value to round
698 * @param int $precision The number of decimal digits to round to
699 *
700 * @return integer|float The rounded value
701 */
702 private function round($value, $precision)
703 {
704 $precision = $this->getUnitializedPrecision($value, $precision);
705
706 $roundingMode = self::$phpRoundingMap[$this->getAttribute(self::ROUNDING_MODE)];
707 $value = round($value, $precision, $roundingMode);
708
709 return $value;
710 }
711
712 /**
713 * Formats a number.
714 *
715 * @param integer|float $value The numeric value to format
716 * @param int $precision The number of decimal digits to use
717 *
718 * @return string The formatted number
719 */
720 private function formatNumber($value, $precision)
721 {
722 $precision = $this->getUnitializedPrecision($value, $precision);
723
724 return number_format($value, $precision, '.', $this->getAttribute(self::GROUPING_USED) ? ',' : '');
725 }
726
727 /**
728 * Returns the precision value if the DECIMAL style is being used and the FRACTION_DIGITS attribute is unitialized.
729 *
730 * @param integer|float $value The value to get the precision from if the FRACTION_DIGITS attribute is unitialized
731 * @param int $precision The precision value to returns if the FRACTION_DIGITS attribute is initialized
732 *
733 * @return int The precision value
734 */
735 private function getUnitializedPrecision($value, $precision)
736 {
737 if ($this->style == self::CURRENCY) {
738 return $precision;
739 }
740
741 if (!$this->isInitializedAttribute(self::FRACTION_DIGITS)) {
742 preg_match('/.*\.(.*)/', (string) $value, $digits);
743 if (isset($digits[1])) {
744 $precision = strlen($digits[1]);
745 }
746 }
747
748 return $precision;
749 }
750
751 /**
752 * Check if the attribute is initialized (value set by client code).
753 *
754 * @param string $attr The attribute name
755 *
756 * @return Boolean true if the value was set by client, false otherwise
757 */
758 private function isInitializedAttribute($attr)
759 {
760 return isset($this->initializedAttributes[$attr]);
761 }
762
763 /**
764 * Returns the numeric value using the $type to convert to the right data type.
765 *
766 * @param mixed $value The value to be converted
767 * @param int $type The type to convert. Can be TYPE_DOUBLE (float) or TYPE_INT32 (int)
768 *
769 * @return integer|float The converted value
770 */
771 private function convertValueDataType($value, $type)
772 {
773 if ($type == self::TYPE_DOUBLE) {
774 $value = (float) $value;
775 } elseif ($type == self::TYPE_INT32) {
776 $value = $this->getInt32Value($value);
777 } elseif ($type == self::TYPE_INT64) {
778 $value = $this->getInt64Value($value);
779 }
780
781 return $value;
782 }
783
784 /**
785 * Convert the value data type to int or returns false if the value is out of the integer value range.
786 *
787 * @param mixed $value The value to be converted
788 *
789 * @return int The converted value
790 */
791 private function getInt32Value($value)
792 {
793 if ($value > self::$int32Range['positive'] || $value < self::$int32Range['negative']) {
794 return false;
795 }
796
797 return (int) $value;
798 }
799
800 /**
801 * Convert the value data type to int or returns false if the value is out of the integer value range.
802 *
803 * @param mixed $value The value to be converted
804 *
805 * @return int|float The converted value
806 *
807 * @see https://bugs.php.net/bug.php?id=59597 Bug #59597
808 */
809 private function getInt64Value($value)
810 {
811 if ($value > self::$int64Range['positive'] || $value < self::$int64Range['negative']) {
812 return false;
813 }
814
815 if (PHP_INT_SIZE !== 8 && ($value > self::$int32Range['positive'] || $value <= self::$int32Range['negative'])) {
816 // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4
817 // The negative PHP_INT_MAX was being converted to float
818 if (
819 $value == self::$int32Range['negative'] &&
820 (
821 (version_compare(PHP_VERSION, '5.4.0', '<') && version_compare(PHP_VERSION, '5.3.14', '>=')) ||
822 version_compare(PHP_VERSION, '5.4.4', '>=')
823 )
824 ) {
825 return (int) $value;
826 }
827
828 return (float) $value;
829 }
830
831 if (PHP_INT_SIZE === 8) {
832 // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4
833 // A 32 bit integer was being generated instead of a 64 bit integer
834 if (
835 ($value > self::$int32Range['positive'] || $value < self::$int32Range['negative']) &&
836 (
837 (version_compare(PHP_VERSION, '5.3.14', '<')) ||
838 (version_compare(PHP_VERSION, '5.4.0', '>=') && version_compare(PHP_VERSION, '5.4.4', '<'))
839 )
840 ) {
841 $value = (-2147483648 - ($value % -2147483648)) * ($value / abs($value));
842 }
843 }
844
845 return (int) $value;
846 }
847
848 /**
849 * Check if the rounding mode is invalid.
850 *
851 * @param int $value The rounding mode value to check
852 *
853 * @return Boolean true if the rounding mode is invalid, false otherwise
854 */
855 private function isInvalidRoundingMode($value)
856 {
857 if (in_array($value, self::$roundingModes, true)) {
858 return false;
859 }
860
861 return true;
862 }
863
864 /**
865 * Returns the normalized value for the GROUPING_USED attribute. Any value that can be converted to int will be
866 * cast to Boolean and then to int again. This way, negative values are converted to 1 and string values to 0.
867 *
868 * @param mixed $value The value to be normalized
869 *
870 * @return int The normalized value for the attribute (0 or 1)
871 */
872 private function normalizeGroupingUsedValue($value)
873 {
874 return (int) (Boolean) (int) $value;
875 }
876
877 /**
878 * Returns the normalized value for the FRACTION_DIGITS attribute. The value is converted to int and if negative,
879 * the returned value will be 0.
880 *
881 * @param mixed $value The value to be normalized
882 *
883 * @return int The normalized value for the attribute
884 */
885 private function normalizeFractionDigitsValue($value)
886 {
887 $value = (int) $value;
888
889 return (0 > $value) ? 0 : $value;
890 }
891}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/README.md b/vendor/symfony/intl/Symfony/Component/Intl/README.md
new file mode 100644
index 00000000..ef4ba505
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/README.md
@@ -0,0 +1,25 @@
1Intl Component
2=============
3
4A PHP replacement layer for the C intl extension that includes additional data
5from the ICU library.
6
7The replacement layer is limited to the locale "en". If you want to use other
8locales, you should [install the intl extension] [1] instead.
9
10Documentation
11-------------
12
13The documentation for the component can be found [online] [2].
14
15Resources
16---------
17
18You can run the unit tests with the following command:
19
20 $ cd path/to/Symfony/Component/Intl/
21 $ composer.phar install --dev
22 $ phpunit
23
24[0]: http://www.php.net/manual/en/intl.setup.php
25[1]: http://symfony.com/doc/2.3/components/intl.html
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/AbstractBundle.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/AbstractBundle.php
new file mode 100644
index 00000000..d1d523c4
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/AbstractBundle.php
@@ -0,0 +1,71 @@
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\ResourceBundle;
13
14use Symfony\Component\Intl\Intl;
15use Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReaderInterface;
16
17/**
18 * Base class for {@link ResourceBundleInterface} implementations.
19 *
20 * @author Bernhard Schussek <bschussek@gmail.com>
21 */
22abstract class AbstractBundle implements ResourceBundleInterface
23{
24 /**
25 * @var string
26 */
27 private $path;
28
29 /**
30 * @var StructuredBundleReaderInterface
31 */
32 private $reader;
33
34 /**
35 * Creates a bundle at the given path using the given reader for reading
36 * bundle entries.
37 *
38 * @param string $path The path to the bundle.
39 * @param StructuredBundleReaderInterface $reader The reader for reading
40 * the bundle.
41 */
42 public function __construct($path, StructuredBundleReaderInterface $reader)
43 {
44 $this->path = $path;
45 $this->reader = $reader;
46 }
47
48 /**
49 * {@inheritdoc}
50 */
51 public function getLocales()
52 {
53 return $this->reader->getLocales($this->path);
54 }
55
56 /**
57 * Proxy method for {@link StructuredBundleReaderInterface#read}.
58 */
59 protected function read($locale)
60 {
61 return $this->reader->read($this->path, $locale);
62 }
63
64 /**
65 * Proxy method for {@link StructuredBundleReaderInterface#readEntry}.
66 */
67 protected function readEntry($locale, array $indices, $mergeFallback = false)
68 {
69 return $this->reader->readEntry($this->path, $locale, $indices, $mergeFallback);
70 }
71}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Compiler/BundleCompiler.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Compiler/BundleCompiler.php
new file mode 100644
index 00000000..174aa179
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Compiler/BundleCompiler.php
@@ -0,0 +1,71 @@
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\ResourceBundle\Compiler;
13
14use Symfony\Component\Intl\Exception\RuntimeException;
15
16/**
17 * Compiles .txt resource bundles to binary .res files.
18 *
19 * @author Bernhard Schussek <bschussek@gmail.com>
20 */
21class BundleCompiler implements BundleCompilerInterface
22{
23 /**
24 * @var string The path to the "genrb" executable.
25 */
26 private $genrb;
27
28 /**
29 * Creates a new compiler based on the "genrb" executable.
30 *
31 * @param string $genrb Optional. The path to the "genrb" executable.
32 * @param string $envVars Optional. Environment variables to be loaded when
33 * running "genrb".
34 *
35 * @throws RuntimeException If the "genrb" cannot be found.
36 */
37 public function __construct($genrb = 'genrb', $envVars = '')
38 {
39 exec('which ' . $genrb, $output, $status);
40
41 if (0 !== $status) {
42 throw new RuntimeException(sprintf(
43 'The command "%s" is not installed',
44 $genrb
45 ));
46 }
47
48 $this->genrb = ($envVars ? $envVars . ' ' : '') . $genrb;
49 }
50
51 /**
52 * {@inheritdoc}
53 */
54 public function compile($sourcePath, $targetDir)
55 {
56 if (is_dir($sourcePath)) {
57 $sourcePath .= '/*.txt';
58 }
59
60 exec($this->genrb.' --quiet -e UTF-8 -d '.$targetDir.' '.$sourcePath, $output, $status);
61
62 if ($status !== 0) {
63 throw new RuntimeException(sprintf(
64 'genrb failed with status %d while compiling %s to %s.',
65 $status,
66 $sourcePath,
67 $targetDir
68 ));
69 }
70 }
71}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Compiler/BundleCompilerInterface.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Compiler/BundleCompilerInterface.php
new file mode 100644
index 00000000..6184ea3e
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Compiler/BundleCompilerInterface.php
@@ -0,0 +1,29 @@
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\ResourceBundle\Compiler;
13
14/**
15 * Compiles a resource bundle.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19interface BundleCompilerInterface
20{
21 /**
22 * Compiles a resource bundle at the given source to the given target
23 * directory.
24 *
25 * @param string $sourcePath
26 * @param string $targetDir
27 */
28 public function compile($sourcePath, $targetDir);
29}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/CurrencyBundle.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/CurrencyBundle.php
new file mode 100644
index 00000000..6f2a0ed3
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/CurrencyBundle.php
@@ -0,0 +1,94 @@
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\ResourceBundle;
13
14/**
15 * Default implementation of {@link CurrencyBundleInterface}.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class CurrencyBundle extends AbstractBundle implements CurrencyBundleInterface
20{
21 const INDEX_NAME = 0;
22
23 const INDEX_SYMBOL = 1;
24
25 const INDEX_FRACTION_DIGITS = 2;
26
27 const INDEX_ROUNDING_INCREMENT = 3;
28
29 /**
30 * {@inheritdoc}
31 */
32 public function getCurrencySymbol($currency, $locale = null)
33 {
34 if (null === $locale) {
35 $locale = \Locale::getDefault();
36 }
37
38 return $this->readEntry($locale, array('Currencies', $currency, static::INDEX_SYMBOL));
39 }
40
41 /**
42 * {@inheritdoc}
43 */
44 public function getCurrencyName($currency, $locale = null)
45 {
46 if (null === $locale) {
47 $locale = \Locale::getDefault();
48 }
49
50 return $this->readEntry($locale, array('Currencies', $currency, static::INDEX_NAME));
51 }
52
53 /**
54 * {@inheritdoc}
55 */
56 public function getCurrencyNames($locale = null)
57 {
58 if (null === $locale) {
59 $locale = \Locale::getDefault();
60 }
61
62 if (null === ($currencies = $this->readEntry($locale, array('Currencies')))) {
63 return array();
64 }
65
66 if ($currencies instanceof \Traversable) {
67 $currencies = iterator_to_array($currencies);
68 }
69
70 $index = static::INDEX_NAME;
71
72 array_walk($currencies, function (&$value) use ($index) {
73 $value = $value[$index];
74 });
75
76 return $currencies;
77 }
78
79 /**
80 * {@inheritdoc}
81 */
82 public function getFractionDigits($currency)
83 {
84 return $this->readEntry('en', array('Currencies', $currency, static::INDEX_FRACTION_DIGITS));
85 }
86
87 /**
88 * {@inheritdoc}
89 */
90 public function getRoundingIncrement($currency)
91 {
92 return $this->readEntry('en', array('Currencies', $currency, static::INDEX_ROUNDING_INCREMENT));
93 }
94}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/CurrencyBundleInterface.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/CurrencyBundleInterface.php
new file mode 100644
index 00000000..1a88e937
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/CurrencyBundleInterface.php
@@ -0,0 +1,74 @@
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\ResourceBundle;
13
14/**
15 * Gives access to currency-related ICU data.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19interface CurrencyBundleInterface extends ResourceBundleInterface
20{
21 /**
22 * Returns the symbol used for a currency.
23 *
24 * @param string $currency A currency code (e.g. "EUR").
25 * @param string $locale Optional. The locale to return the result in.
26 * Defaults to {@link \Locale::getDefault()}.
27 *
28 * @return string|null The currency symbol or NULL if not found.
29 */
30 public function getCurrencySymbol($currency, $locale = null);
31
32 /**
33 * Returns the name of a currency.
34 *
35 * @param string $currency A currency code (e.g. "EUR").
36 * @param string $locale Optional. The locale to return the name in.
37 * Defaults to {@link \Locale::getDefault()}.
38 *
39 * @return string|null The name of the currency or NULL if not found.
40 */
41 public function getCurrencyName($currency, $locale = null);
42
43 /**
44 * Returns the names of all known currencies.
45 *
46 * @param string $locale Optional. The locale to return the names in.
47 * Defaults to {@link \Locale::getDefault()}.
48 *
49 * @return string[] A list of currency names indexed by currency codes.
50 */
51 public function getCurrencyNames($locale = null);
52
53 /**
54 * Returns the number of digits after the comma of a currency.
55 *
56 * @param string $currency A currency code (e.g. "EUR").
57 *
58 * @return integer|null The number of digits after the comma or NULL if not found.
59 */
60 public function getFractionDigits($currency);
61
62 /**
63 * Returns the rounding increment of a currency.
64 *
65 * The rounding increment indicates to which number a currency is rounded.
66 * For example, 1230 rounded to the nearest 50 is 1250. 1.234 rounded to the
67 * nearest 0.65 is 1.3.
68 *
69 * @param string $currency A currency code (e.g. "EUR").
70 *
71 * @return float|integer|null The rounding increment or NULL if not found.
72 */
73 public function getRoundingIncrement($currency);
74}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php
new file mode 100644
index 00000000..c449f9c1
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php
@@ -0,0 +1,115 @@
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\ResourceBundle;
13
14/**
15 * Default implementation of {@link LanguageBundleInterface}.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class LanguageBundle extends AbstractBundle implements LanguageBundleInterface
20{
21 /**
22 * {@inheritdoc}
23 */
24 public function getLanguageName($lang, $region = null, $locale = null)
25 {
26 if (null === $locale) {
27 $locale = \Locale::getDefault();
28 }
29
30 if (null === ($languages = $this->readEntry($locale, array('Languages')))) {
31 return null;
32 }
33
34 // Some languages are translated together with their region,
35 // i.e. "en_GB" is translated as "British English"
36 if (null !== $region && isset($languages[$lang.'_'.$region])) {
37 return $languages[$lang.'_'.$region];
38 }
39
40 return $languages[$lang];
41 }
42
43 /**
44 * {@inheritdoc}
45 */
46 public function getLanguageNames($locale = null)
47 {
48 if (null === $locale) {
49 $locale = \Locale::getDefault();
50 }
51
52 if (null === ($languages = $this->readEntry($locale, array('Languages')))) {
53 return array();
54 }
55
56 if ($languages instanceof \Traversable) {
57 $languages = iterator_to_array($languages);
58 }
59
60 return $languages;
61 }
62
63 /**
64 * {@inheritdoc}
65 */
66 public function getScriptName($script, $lang = null, $locale = null)
67 {
68 if (null === $locale) {
69 $locale = \Locale::getDefault();
70 }
71
72 $data = $this->read($locale);
73
74 // Some languages are translated together with their script,
75 // e.g. "zh_Hans" is translated as "Simplified Chinese"
76 if (null !== $lang && isset($data['Languages'][$lang.'_'.$script])) {
77 $langName = $data['Languages'][$lang.'_'.$script];
78
79 // If the script is appended in braces, extract it, e.g. "zh_Hans"
80 // is translated as "Chinesisch (vereinfacht)" in locale "de"
81 if (strpos($langName, '(') !== false) {
82 list($langName, $scriptName) = preg_split('/[\s()]/', $langName, null, PREG_SPLIT_NO_EMPTY);
83
84 return $scriptName;
85 }
86 }
87
88 // "af" (Afrikaans) has no "Scripts" block
89 if (!isset($data['Scripts'][$script])) {
90 return null;
91 }
92
93 return $data['Scripts'][$script];
94 }
95
96 /**
97 * {@inheritdoc}
98 */
99 public function getScriptNames($locale = null)
100 {
101 if (null === $locale) {
102 $locale = \Locale::getDefault();
103 }
104
105 if (null === ($scripts = $this->readEntry($locale, array('Scripts')))) {
106 return array();
107 }
108
109 if ($scripts instanceof \Traversable) {
110 $scripts = iterator_to_array($scripts);
111 }
112
113 return $scripts;
114 }
115}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/LanguageBundleInterface.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/LanguageBundleInterface.php
new file mode 100644
index 00000000..de50bda0
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/LanguageBundleInterface.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\ResourceBundle;
13
14/**
15 * Gives access to language-related ICU data.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19interface LanguageBundleInterface extends ResourceBundleInterface
20{
21 /**
22 * Returns the name of a language.
23 *
24 * @param string $lang A language code (e.g. "en").
25 * @param string|null $region Optional. A region code (e.g. "US").
26 * @param string $locale Optional. The locale to return the name in.
27 * Defaults to {@link \Locale::getDefault()}.
28 *
29 * @return string|null The name of the language or NULL if not found.
30 */
31 public function getLanguageName($lang, $region = null, $locale = null);
32
33 /**
34 * Returns the names of all known languages.
35 *
36 * @param string $locale Optional. The locale to return the names in.
37 * Defaults to {@link \Locale::getDefault()}.
38 *
39 * @return string[] A list of language names indexed by language codes.
40 */
41 public function getLanguageNames($locale = null);
42
43 /**
44 * Returns the name of a script.
45 *
46 * @param string $script A script code (e.g. "Hans").
47 * @param string $lang Optional. A language code (e.g. "zh").
48 * @param string $locale Optional. The locale to return the name in.
49 * Defaults to {@link \Locale::getDefault()}.
50 *
51 * @return string|null The name of the script or NULL if not found.
52 */
53 public function getScriptName($script, $lang = null, $locale = null);
54
55 /**
56 * Returns the names of all known scripts.
57 *
58 * @param string $locale Optional. The locale to return the names in.
59 * Defaults to {@link \Locale::getDefault()}.
60 *
61 * @return string[] A list of script names indexed by script codes.
62 */
63 public function getScriptNames($locale = null);
64}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/LocaleBundle.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/LocaleBundle.php
new file mode 100644
index 00000000..6f6cdfcb
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/LocaleBundle.php
@@ -0,0 +1,52 @@
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\ResourceBundle;
13
14/**
15 * Default implementation of {@link LocaleBundleInterface}.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class LocaleBundle extends AbstractBundle implements LocaleBundleInterface
20{
21 /**
22 * {@inheritdoc}
23 */
24 public function getLocaleName($ofLocale, $locale = null)
25 {
26 if (null === $locale) {
27 $locale = \Locale::getDefault();
28 }
29
30 return $this->readEntry($locale, array('Locales', $ofLocale));
31 }
32
33 /**
34 * {@inheritdoc}
35 */
36 public function getLocaleNames($locale = null)
37 {
38 if (null === $locale) {
39 $locale = \Locale::getDefault();
40 }
41
42 if (null === ($locales = $this->readEntry($locale, array('Locales')))) {
43 return array();
44 }
45
46 if ($locales instanceof \Traversable) {
47 $locales = iterator_to_array($locales);
48 }
49
50 return $locales;
51 }
52}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/LocaleBundleInterface.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/LocaleBundleInterface.php
new file mode 100644
index 00000000..daf5be68
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/LocaleBundleInterface.php
@@ -0,0 +1,41 @@
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\ResourceBundle;
13
14/**
15 * Gives access to locale-related ICU data.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19interface LocaleBundleInterface extends ResourceBundleInterface
20{
21 /**
22 * Returns the name of a locale.
23 *
24 * @param string $ofLocale The locale to return the name of (e.g. "de_AT").
25 * @param string $locale Optional. The locale to return the name in.
26 * Defaults to {@link \Locale::getDefault()}.
27 *
28 * @return string|null The name of the locale or NULL if not found.
29 */
30 public function getLocaleName($ofLocale, $locale = null);
31
32 /**
33 * Returns the names of all known locales.
34 *
35 * @param string $locale Optional. The locale to return the names in.
36 * Defaults to {@link \Locale::getDefault()}.
37 *
38 * @return string[] A list of locale names indexed by locale codes.
39 */
40 public function getLocaleNames($locale = null);
41}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/AbstractBundleReader.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/AbstractBundleReader.php
new file mode 100644
index 00000000..c30693ac
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/AbstractBundleReader.php
@@ -0,0 +1,42 @@
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\ResourceBundle\Reader;
13
14/**
15 * Base class for {@link BundleReaderInterface} implementations.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19abstract class AbstractBundleReader implements BundleReaderInterface
20{
21 /**
22 * {@inheritdoc}
23 */
24 public function getLocales($path)
25 {
26 $extension = '.' . $this->getFileExtension();
27 $locales = glob($path . '/*' . $extension);
28
29 // Remove file extension and sort
30 array_walk($locales, function (&$locale) use ($extension) { $locale = basename($locale, $extension); });
31 sort($locales);
32
33 return $locales;
34 }
35
36 /**
37 * Returns the extension of locale files in this bundle.
38 *
39 * @return string The file extension (without leading dot).
40 */
41 abstract protected function getFileExtension();
42}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/BinaryBundleReader.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/BinaryBundleReader.php
new file mode 100644
index 00000000..56cef806
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/BinaryBundleReader.php
@@ -0,0 +1,51 @@
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\ResourceBundle\Reader;
13
14use Symfony\Component\Intl\Exception\RuntimeException;
15use Symfony\Component\Intl\ResourceBundle\Util\ArrayAccessibleResourceBundle;
16
17/**
18 * Reads binary .res resource bundles.
19 *
20 * @author Bernhard Schussek <bschussek@gmail.com>
21 */
22class BinaryBundleReader extends AbstractBundleReader implements BundleReaderInterface
23{
24 /**
25 * {@inheritdoc}
26 */
27 public function read($path, $locale)
28 {
29 // Point for future extension: Modify this class so that it works also
30 // if the \ResourceBundle class is not available.
31 $bundle = new \ResourceBundle($locale, $path);
32
33 if (null === $bundle) {
34 throw new RuntimeException(sprintf(
35 'Could not load the resource bundle "%s/%s.res".',
36 $path,
37 $locale
38 ));
39 }
40
41 return new ArrayAccessibleResourceBundle($bundle);
42 }
43
44 /**
45 * {@inheritdoc}
46 */
47 protected function getFileExtension()
48 {
49 return 'res';
50 }
51}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/BufferedBundleReader.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/BufferedBundleReader.php
new file mode 100644
index 00000000..e44074b1
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/BufferedBundleReader.php
@@ -0,0 +1,62 @@
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\ResourceBundle\Reader;
13
14use Symfony\Component\Intl\ResourceBundle\Util\RingBuffer;
15
16/**
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class BufferedBundleReader implements BundleReaderInterface
20{
21 /**
22 * @var BundleReaderInterface
23 */
24 private $reader;
25
26 private $buffer;
27
28 /**
29 * Buffers a given reader.
30 *
31 * @param BundleReaderInterface $reader The reader to buffer.
32 * @param integer $bufferSize The number of entries to store
33 * in the buffer.
34 */
35 public function __construct(BundleReaderInterface $reader, $bufferSize)
36 {
37 $this->reader = $reader;
38 $this->buffer = new RingBuffer($bufferSize);
39 }
40
41 /**
42 * {@inheritdoc}
43 */
44 public function read($path, $locale)
45 {
46 $hash = $path . '//' . $locale;
47
48 if (!isset($this->buffer[$hash])) {
49 $this->buffer[$hash] = $this->reader->read($path, $locale);
50 }
51
52 return $this->buffer[$hash];
53 }
54
55 /**
56 * {@inheritdoc}
57 */
58 public function getLocales($path)
59 {
60 return $this->reader->getLocales($path);
61 }
62}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/BundleReaderInterface.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/BundleReaderInterface.php
new file mode 100644
index 00000000..bc485cd5
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/BundleReaderInterface.php
@@ -0,0 +1,40 @@
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\ResourceBundle\Reader;
13
14/**
15 * Reads resource bundle files.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19interface BundleReaderInterface
20{
21 /**
22 * Reads a resource bundle.
23 *
24 * @param string $path The path to the resource bundle.
25 * @param string $locale The locale to read.
26 *
27 * @return mixed Returns an array or {@link \ArrayAccess} instance for
28 * complex data, a scalar value otherwise.
29 */
30 public function read($path, $locale);
31
32 /**
33 * Reads the available locales of a resource bundle.
34 *
35 * @param string $path The path to the resource bundle.
36 *
37 * @return string[] A list of supported locale codes.
38 */
39 public function getLocales($path);
40}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/PhpBundleReader.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/PhpBundleReader.php
new file mode 100644
index 00000000..663bcc9d
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/PhpBundleReader.php
@@ -0,0 +1,61 @@
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\ResourceBundle\Reader;
13
14use Symfony\Component\Intl\Exception\InvalidArgumentException;
15use Symfony\Component\Intl\Exception\RuntimeException;
16
17/**
18 * Reads .php resource bundles.
19 *
20 * @author Bernhard Schussek <bschussek@gmail.com>
21 */
22class PhpBundleReader extends AbstractBundleReader implements BundleReaderInterface
23{
24 /**
25 * {@inheritdoc}
26 */
27 public function read($path, $locale)
28 {
29 if ('en' !== $locale) {
30 throw new InvalidArgumentException('Only the locale "en" is supported.');
31 }
32
33 $fileName = $path . '/' . $locale . '.php';
34
35 if (!file_exists($fileName)) {
36 throw new RuntimeException(sprintf(
37 'The resource bundle "%s/%s.php" does not exist.',
38 $path,
39 $locale
40 ));
41 }
42
43 if (!is_file($fileName)) {
44 throw new RuntimeException(sprintf(
45 'The resource bundle "%s/%s.php" is not a file.',
46 $path,
47 $locale
48 ));
49 }
50
51 return include $fileName;
52 }
53
54 /**
55 * {@inheritdoc}
56 */
57 protected function getFileExtension()
58 {
59 return 'php';
60 }
61}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReader.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReader.php
new file mode 100644
index 00000000..e3656fe2
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReader.php
@@ -0,0 +1,113 @@
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\ResourceBundle\Reader;
13
14use Symfony\Component\Intl\ResourceBundle\Util\RecursiveArrayAccess;
15
16/**
17 * A structured reader wrapping an existing resource bundle reader.
18 *
19 * @author Bernhard Schussek <bschussek@gmail.com>
20 *
21 * @see StructuredResourceBundleBundleReaderInterface
22 */
23class StructuredBundleReader implements StructuredBundleReaderInterface
24{
25 /**
26 * @var BundleReaderInterface
27 */
28 private $reader;
29
30 /**
31 * Creates an entry reader based on the given resource bundle reader.
32 *
33 * @param BundleReaderInterface $reader A resource bundle reader to use.
34 */
35 public function __construct(BundleReaderInterface $reader)
36 {
37 $this->reader = $reader;
38 }
39
40 /**
41 * {@inheritdoc}
42 */
43 public function read($path, $locale)
44 {
45 return $this->reader->read($path, $locale);
46 }
47
48 /**
49 * {@inheritdoc}
50 */
51 public function getLocales($path)
52 {
53 return $this->reader->getLocales($path);
54 }
55
56 /**
57 * {@inheritdoc}
58 */
59 public function readEntry($path, $locale, array $indices, $fallback = true)
60 {
61 $data = $this->reader->read($path, $locale);
62
63 $entry = RecursiveArrayAccess::get($data, $indices);
64 $multivalued = is_array($entry) || $entry instanceof \Traversable;
65
66 if (!($fallback && (null === $entry || $multivalued))) {
67 return $entry;
68 }
69
70 if (null !== ($fallbackLocale = $this->getFallbackLocale($locale))) {
71 $parentEntry = $this->readEntry($path, $fallbackLocale, $indices, true);
72
73 if ($entry || $parentEntry) {
74 $multivalued = $multivalued || is_array($parentEntry) || $parentEntry instanceof \Traversable;
75
76 if ($multivalued) {
77 if ($entry instanceof \Traversable) {
78 $entry = iterator_to_array($entry);
79 }
80
81 if ($parentEntry instanceof \Traversable) {
82 $parentEntry = iterator_to_array($parentEntry);
83 }
84
85 $entry = array_merge(
86 $parentEntry ?: array(),
87 $entry ?: array()
88 );
89 } else {
90 $entry = null === $entry ? $parentEntry : $entry;
91 }
92 }
93 }
94
95 return $entry;
96 }
97
98 /**
99 * Returns the fallback locale for a given locale, if any
100 *
101 * @param string $locale The locale to find the fallback for.
102 *
103 * @return string|null The fallback locale, or null if no parent exists
104 */
105 private function getFallbackLocale($locale)
106 {
107 if (false === $pos = strrpos($locale, '_')) {
108 return null;
109 }
110
111 return substr($locale, 0, $pos);
112 }
113}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReaderInterface.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReaderInterface.php
new file mode 100644
index 00000000..c22ad93b
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReaderInterface.php
@@ -0,0 +1,50 @@
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\ResourceBundle\Reader;
13
14/**
15 * Reads individual entries of a resource file.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19interface StructuredBundleReaderInterface extends BundleReaderInterface
20{
21 /**
22 * Reads an entry from a resource bundle.
23 *
24 * An entry can be selected from the resource bundle by passing the path
25 * to that entry in the bundle. For example, if the bundle is structured
26 * like this:
27 *
28 * TopLevel
29 * NestedLevel
30 * Entry: Value
31 *
32 * Then the value can be read by calling:
33 *
34 * $reader->readEntry('...', 'en', array('TopLevel', 'NestedLevel', 'Entry'));
35 *
36 * @param string $path The path to the resource bundle.
37 * @param string $locale The locale to read.
38 * @param string[] $indices The indices to read from the bundle.
39 * @param Boolean $fallback Whether to merge the value with the value from
40 * the fallback locale (e.g. "en" for "en_GB").
41 * Only applicable if the result is multivalued
42 * (i.e. array or \ArrayAccess) or cannot be found
43 * in the requested locale.
44 *
45 * @return mixed Returns an array or {@link \ArrayAccess} instance for
46 * complex data, a scalar value for simple data and NULL
47 * if the given path could not be accessed.
48 */
49 public function readEntry($path, $locale, array $indices, $fallback = true);
50}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/RegionBundle.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/RegionBundle.php
new file mode 100644
index 00000000..a3cd9bd3
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/RegionBundle.php
@@ -0,0 +1,52 @@
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\ResourceBundle;
13
14/**
15 * Default implementation of {@link RegionBundleInterface}.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class RegionBundle extends AbstractBundle implements RegionBundleInterface
20{
21 /**
22 * {@inheritdoc}
23 */
24 public function getCountryName($country, $locale = null)
25 {
26 if (null === $locale) {
27 $locale = \Locale::getDefault();
28 }
29
30 return $this->readEntry($locale, array('Countries', $country));
31 }
32
33 /**
34 * {@inheritdoc}
35 */
36 public function getCountryNames($locale = null)
37 {
38 if (null === $locale) {
39 $locale = \Locale::getDefault();
40 }
41
42 if (null === ($countries = $this->readEntry($locale, array('Countries')))) {
43 return array();
44 }
45
46 if ($countries instanceof \Traversable) {
47 $countries = iterator_to_array($countries);
48 }
49
50 return $countries;
51 }
52}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/RegionBundleInterface.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/RegionBundleInterface.php
new file mode 100644
index 00000000..4e55f2dc
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/RegionBundleInterface.php
@@ -0,0 +1,41 @@
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\ResourceBundle;
13
14/**
15 * Gives access to region-related ICU data.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19interface RegionBundleInterface extends ResourceBundleInterface
20{
21 /**
22 * Returns the name of a country.
23 *
24 * @param string $country A country code (e.g. "US").
25 * @param string $locale Optional. The locale to return the name in.
26 * Defaults to {@link \Locale::getDefault()}.
27 *
28 * @return string|null The name of the country or NULL if not found.
29 */
30 public function getCountryName($country, $locale = null);
31
32 /**
33 * Returns the names of all known countries.
34 *
35 * @param string $locale Optional. The locale to return the names in.
36 * Defaults to {@link \Locale::getDefault()}.
37 *
38 * @return string[] A list of country names indexed by country codes.
39 */
40 public function getCountryNames($locale = null);
41}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/ResourceBundleInterface.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/ResourceBundleInterface.php
new file mode 100644
index 00000000..497a66a3
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/ResourceBundleInterface.php
@@ -0,0 +1,27 @@
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\ResourceBundle;
13
14/**
15 * Gives access to ICU data.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19interface ResourceBundleInterface
20{
21 /**
22 * Returns the list of locales that this bundle supports.
23 *
24 * @return string[] A list of locale codes.
25 */
26 public function getLocales();
27}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/BundleTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/BundleTransformer.php
new file mode 100644
index 00000000..0692d6fe
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/BundleTransformer.php
@@ -0,0 +1,96 @@
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\ResourceBundle\Transformer;
13
14use Symfony\Component\Intl\Exception\RuntimeException;
15use Symfony\Component\Intl\ResourceBundle\Transformer\Rule\TransformationRuleInterface;
16use Symfony\Component\Intl\ResourceBundle\Writer\PhpBundleWriter;
17
18/**
19 * Compiles a number of resource bundles based on predefined compilation rules.
20 *
21 * @author Bernhard Schussek <bschussek@gmail.com>
22 */
23class BundleTransformer
24{
25 /**
26 * @var TransformationRuleInterface[]
27 */
28 private $rules = array();
29
30 /**
31 * Adds a new compilation rule.
32 *
33 * @param TransformationRuleInterface $rule The compilation rule.
34 */
35 public function addRule(TransformationRuleInterface $rule)
36 {
37 $this->rules[] = $rule;
38 }
39
40 /**
41 * Runs the compilation with the given compilation context.
42 *
43 * @param CompilationContextInterface $context The context storing information
44 * needed to run the compilation.
45 *
46 * @throws RuntimeException If any of the files to be compiled by the loaded
47 * compilation rules does not exist.
48 */
49 public function compileBundles(CompilationContextInterface $context)
50 {
51 $filesystem = $context->getFilesystem();
52 $compiler = $context->getCompiler();
53
54 $filesystem->remove($context->getBinaryDir());
55 $filesystem->mkdir($context->getBinaryDir());
56
57 foreach ($this->rules as $rule) {
58 $filesystem->mkdir($context->getBinaryDir() . '/' . $rule->getBundleName());
59
60 $resources = (array) $rule->beforeCompile($context);
61
62 foreach ($resources as $resource) {
63 if (!file_exists($resource)) {
64 throw new RuntimeException(sprintf(
65 'The file "%s" to be compiled by %s does not exist.',
66 $resource,
67 get_class($rule)
68 ));
69 }
70
71 $compiler->compile($resource, $context->getBinaryDir() . '/' . $rule->getBundleName());
72 }
73
74 $rule->afterCompile($context);
75 }
76 }
77
78 public function createStubs(StubbingContextInterface $context)
79 {
80 $filesystem = $context->getFilesystem();
81 $phpWriter = new PhpBundleWriter();
82
83 $filesystem->remove($context->getStubDir());
84 $filesystem->mkdir($context->getStubDir());
85
86 foreach ($this->rules as $rule) {
87 $filesystem->mkdir($context->getStubDir() . '/' . $rule->getBundleName());
88
89 $data = $rule->beforeCreateStub($context);
90
91 $phpWriter->write($context->getStubDir() . '/' . $rule->getBundleName(), 'en', $data);
92
93 $rule->afterCreateStub($context);
94 }
95 }
96}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContext.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContext.php
new file mode 100644
index 00000000..cdc1951b
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContext.php
@@ -0,0 +1,97 @@
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\ResourceBundle\Transformer;
13
14use Symfony\Component\Filesystem\Filesystem;
15use Symfony\Component\Intl\ResourceBundle\Compiler\BundleCompilerInterface;
16
17/**
18 * Default implementation of {@link CompilationContextInterface}.
19 *
20 * @author Bernhard Schussek <bschussek@gmail.com>
21 */
22class CompilationContext implements CompilationContextInterface
23{
24 /**
25 * @var string
26 */
27 private $sourceDir;
28
29 /**
30 * @var string
31 */
32 private $binaryDir;
33
34 /**
35 * @var FileSystem
36 */
37 private $filesystem;
38
39 /**
40 * @var BundleCompilerInterface
41 */
42 private $compiler;
43
44 /**
45 * @var string
46 */
47 private $icuVersion;
48
49 public function __construct($sourceDir, $binaryDir, Filesystem $filesystem, BundleCompilerInterface $compiler, $icuVersion)
50 {
51 $this->sourceDir = $sourceDir;
52 $this->binaryDir = $binaryDir;
53 $this->filesystem = $filesystem;
54 $this->compiler = $compiler;
55 $this->icuVersion = $icuVersion;
56 }
57
58 /**
59 * {@inheritdoc}
60 */
61 public function getSourceDir()
62 {
63 return $this->sourceDir;
64 }
65
66 /**
67 * {@inheritdoc}
68 */
69 public function getBinaryDir()
70 {
71 return $this->binaryDir;
72 }
73
74 /**
75 * {@inheritdoc}
76 */
77 public function getFilesystem()
78 {
79 return $this->filesystem;
80 }
81
82 /**
83 * {@inheritdoc}
84 */
85 public function getCompiler()
86 {
87 return $this->compiler;
88 }
89
90 /**
91 * {@inheritdoc}
92 */
93 public function getIcuVersion()
94 {
95 return $this->icuVersion;
96 }
97}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContextInterface.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContextInterface.php
new file mode 100644
index 00000000..f05c2807
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContextInterface.php
@@ -0,0 +1,56 @@
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\ResourceBundle\Transformer;
13
14/**
15 * Stores contextual information for resource bundle compilation.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19interface CompilationContextInterface
20{
21 /**
22 * Returns the directory where the source versions of the resource bundles
23 * are stored.
24 *
25 * @return string An absolute path to a directory.
26 */
27 public function getSourceDir();
28
29 /**
30 * Returns the directory where the binary resource bundles are stored.
31 *
32 * @return string An absolute path to a directory.
33 */
34 public function getBinaryDir();
35
36 /**
37 * Returns a tool for manipulating the filesystem.
38 *
39 * @return \Symfony\Component\Filesystem\Filesystem The filesystem manipulator.
40 */
41 public function getFilesystem();
42
43 /**
44 * Returns a resource bundle compiler.
45 *
46 * @return \Symfony\Component\Intl\ResourceBundle\Compiler\BundleCompilerInterface The loaded resource bundle compiler.
47 */
48 public function getCompiler();
49
50 /**
51 * Returns the ICU version of the bundles being converted.
52 *
53 * @return string The ICU version string.
54 */
55 public function getIcuVersion();
56}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/CurrencyBundleTransformationRule.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/CurrencyBundleTransformationRule.php
new file mode 100644
index 00000000..95783b3b
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/CurrencyBundleTransformationRule.php
@@ -0,0 +1,94 @@
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\ResourceBundle\Transformer\Rule;
13
14use Symfony\Component\Intl\Intl;
15use Symfony\Component\Intl\ResourceBundle\CurrencyBundle;
16use Symfony\Component\Intl\ResourceBundle\Transformer\CompilationContextInterface;
17use Symfony\Component\Intl\ResourceBundle\Transformer\StubbingContextInterface;
18use Symfony\Component\Intl\Util\IcuVersion;
19
20/**
21 * The rule for compiling the currency bundle.
22 *
23 * @author Bernhard Schussek <bschussek@gmail.com>
24 */
25class CurrencyBundleTransformationRule implements TransformationRuleInterface
26{
27 /**
28 * {@inheritdoc}
29 */
30 public function getBundleName()
31 {
32 return 'curr';
33 }
34
35 /**
36 * {@inheritdoc}
37 */
38 public function beforeCompile(CompilationContextInterface $context)
39 {
40 // The currency data is contained in the locales and misc bundles
41 // in ICU <= 4.2
42 if (IcuVersion::compare($context->getIcuVersion(), '4.2', '<=', 1)) {
43 return array(
44 $context->getSourceDir() . '/misc/supplementalData.txt',
45 $context->getSourceDir() . '/locales'
46 );
47 }
48
49 return $context->getSourceDir() . '/curr';
50 }
51
52 /**
53 * {@inheritdoc}
54 */
55 public function afterCompile(CompilationContextInterface $context)
56 {
57 // \ResourceBundle does not like locale names with uppercase chars, so rename
58 // the resource file
59 // See: http://bugs.php.net/bug.php?id=54025
60 $fileName = $context->getBinaryDir() . '/curr/supplementalData.res';
61 $fileNameLower = $context->getBinaryDir() . '/curr/supplementaldata.res';
62
63 $context->getFilesystem()->rename($fileName, $fileNameLower);
64 }
65
66 /**
67 * {@inheritdoc}
68 */
69 public function beforeCreateStub(StubbingContextInterface $context)
70 {
71 $currencies = array();
72 $currencyBundle = Intl::getCurrencyBundle();
73
74 foreach ($currencyBundle->getCurrencyNames('en') as $code => $name) {
75 $currencies[$code] = array(
76 CurrencyBundle::INDEX_NAME => $name,
77 CurrencyBundle::INDEX_SYMBOL => $currencyBundle->getCurrencySymbol($code, 'en'),
78 CurrencyBundle::INDEX_FRACTION_DIGITS => $currencyBundle->getFractionDigits($code),
79 CurrencyBundle::INDEX_ROUNDING_INCREMENT => $currencyBundle->getRoundingIncrement($code),
80 );
81 }
82
83 return array(
84 'Currencies' => $currencies,
85 );
86 }
87
88 /**
89 * {@inheritdoc}
90 */
91 public function afterCreateStub(StubbingContextInterface $context)
92 {
93 }
94}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LanguageBundleTransformationRule.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LanguageBundleTransformationRule.php
new file mode 100644
index 00000000..5e6f9018
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LanguageBundleTransformationRule.php
@@ -0,0 +1,71 @@
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\ResourceBundle\Transformer\Rule;
13
14use Symfony\Component\Intl\Intl;
15use Symfony\Component\Intl\ResourceBundle\Transformer\CompilationContextInterface;
16use Symfony\Component\Intl\ResourceBundle\Transformer\StubbingContextInterface;
17use Symfony\Component\Intl\Util\IcuVersion;
18
19/**
20 * The rule for compiling the language bundle.
21 *
22 * @author Bernhard Schussek <bschussek@gmail.com>
23 */
24class LanguageBundleTransformationRule implements TransformationRuleInterface
25{
26 /**
27 * {@inheritdoc}
28 */
29 public function getBundleName()
30 {
31 return 'lang';
32 }
33
34 /**
35 * {@inheritdoc}
36 */
37 public function beforeCompile(CompilationContextInterface $context)
38 {
39 // The language data is contained in the locales bundle in ICU <= 4.2
40 if (IcuVersion::compare($context->getIcuVersion(), '4.2', '<=', 1)) {
41 return $context->getSourceDir() . '/locales';
42 }
43
44 return $context->getSourceDir() . '/lang';
45 }
46
47 /**
48 * {@inheritdoc}
49 */
50 public function afterCompile(CompilationContextInterface $context)
51 {
52 }
53
54 /**
55 * {@inheritdoc}
56 */
57 public function beforeCreateStub(StubbingContextInterface $context)
58 {
59 return array(
60 'Languages' => Intl::getLanguageBundle()->getLanguageNames('en'),
61 'Scripts' => Intl::getLanguageBundle()->getScriptNames('en'),
62 );
63 }
64
65 /**
66 * {@inheritdoc}
67 */
68 public function afterCreateStub(StubbingContextInterface $context)
69 {
70 }
71}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LocaleBundleTransformationRule.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LocaleBundleTransformationRule.php
new file mode 100644
index 00000000..b2576d6e
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LocaleBundleTransformationRule.php
@@ -0,0 +1,251 @@
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\ResourceBundle\Transformer\Rule;
13
14use Symfony\Component\Intl\Exception\RuntimeException;
15use Symfony\Component\Intl\Intl;
16use Symfony\Component\Intl\ResourceBundle\Transformer\CompilationContextInterface;
17use Symfony\Component\Intl\ResourceBundle\Transformer\StubbingContextInterface;
18use Symfony\Component\Intl\ResourceBundle\Writer\TextBundleWriter;
19
20/**
21 * The rule for compiling the locale bundle.
22 *
23 * @author Bernhard Schussek <bschussek@gmail.com>
24 */
25class LocaleBundleTransformationRule implements TransformationRuleInterface
26{
27 /**
28 * @var \Symfony\Component\Intl\ResourceBundle\LanguageBundleInterface
29 */
30 private $languageBundle;
31
32 /**
33 * @var \Symfony\Component\Intl\ResourceBundle\RegionBundleInterface
34 */
35 private $regionBundle;
36
37 public function __construct()
38 {
39 $this->languageBundle = Intl::getLanguageBundle();
40 $this->regionBundle = Intl::getRegionBundle();
41 }
42
43 /**
44 * {@inheritdoc}
45 */
46 public function getBundleName()
47 {
48 return 'locales';
49 }
50
51 /**
52 * {@inheritdoc}
53 */
54 public function beforeCompile(CompilationContextInterface $context)
55 {
56 $tempDir = sys_get_temp_dir() . '/icu-data-locales';
57
58 $context->getFilesystem()->remove($tempDir);
59 $context->getFilesystem()->mkdir($tempDir);
60
61 $this->generateTextFiles($tempDir, $this->scanLocales($context));
62
63 return $tempDir;
64 }
65
66 /**
67 * {@inheritdoc}
68 */
69 public function afterCompile(CompilationContextInterface $context)
70 {
71 $context->getFilesystem()->remove(sys_get_temp_dir() . '/icu-data-locales');
72 }
73
74 /**
75 * {@inheritdoc}
76 */
77 public function beforeCreateStub(StubbingContextInterface $context)
78 {
79 return array(
80 'Locales' => Intl::getLocaleBundle()->getLocaleNames('en'),
81 );
82 }
83
84 /**
85 * {@inheritdoc}
86 */
87 public function afterCreateStub(StubbingContextInterface $context)
88 {
89 }
90
91 private function scanLocales(CompilationContextInterface $context)
92 {
93 $tempDir = sys_get_temp_dir() . '/icu-data-locales-source';
94
95 $context->getFilesystem()->remove($tempDir);
96 $context->getFilesystem()->mkdir($tempDir);
97
98 // Temporarily generate the resource bundles
99 $context->getCompiler()->compile($context->getSourceDir() . '/locales', $tempDir);
100
101 // Discover the list of supported locales, which are the names of the resource
102 // bundles in the "locales" directory
103 $locales = glob($tempDir . '/*.res');
104
105 // Remove file extension and sort
106 array_walk($locales, function (&$locale) { $locale = basename($locale, '.res'); });
107 sort($locales);
108
109 // Delete unneeded locales
110 foreach ($locales as $key => $locale) {
111 // Delete all aliases from the list
112 // i.e., "az_AZ" is an alias for "az_Latn_AZ"
113 $content = file_get_contents($context->getSourceDir() . '/locales/' . $locale . '.txt');
114
115 // The key "%%ALIAS" is not accessible through the \ResourceBundle class,
116 // so look in the original .txt file instead
117 if (strpos($content, '%%ALIAS') !== false) {
118 unset($locales[$key]);
119 }
120
121 // Delete locales that have no content (i.e. only "Version" key)
122 $bundle = new \ResourceBundle($locale, $tempDir);
123
124 if (null === $bundle) {
125 throw new RuntimeException('The resource bundle for locale ' . $locale . ' could not be loaded from directory ' . $tempDir);
126 }
127
128 // There seems to be no other way for identifying all keys in this specific
129 // resource bundle
130 if (array_keys(iterator_to_array($bundle)) === array('Version')) {
131 unset($locales[$key]);
132 }
133 }
134
135 $context->getFilesystem()->remove($tempDir);
136
137 return $locales;
138 }
139
140 private function generateTextFiles($targetDirectory, array $locales)
141 {
142 $displayLocales = array_unique(array_merge(
143 $this->languageBundle->getLocales(),
144 $this->regionBundle->getLocales()
145 ));
146
147 $txtWriter = new TextBundleWriter();
148
149 // Generate a list of locale names in the language of each display locale
150 // Each locale name has the form: "Language (Script, Region, Variant1, ...)
151 // Script, Region and Variants are optional. If none of them is available,
152 // the braces are not printed.
153 foreach ($displayLocales as $displayLocale) {
154 // Don't include ICU's root resource bundle
155 if ('root' === $displayLocale) {
156 continue;
157 }
158
159 $names = array();
160
161 foreach ($locales as $locale) {
162 // Don't include ICU's root resource bundle
163 if ($locale === 'root') {
164 continue;
165 }
166
167 if (null !== ($name = $this->generateLocaleName($locale, $displayLocale))) {
168 $names[$locale] = $name;
169 }
170 }
171
172 // If no names could be generated for the current locale, skip it
173 if (0 === count($names)) {
174 continue;
175 }
176
177 $txtWriter->write($targetDirectory, $displayLocale, array('Locales' => $names));
178 }
179 }
180
181 private function generateLocaleName($locale, $displayLocale)
182 {
183 $name = null;
184
185 $lang = \Locale::getPrimaryLanguage($locale);
186 $script = \Locale::getScript($locale);
187 $region = \Locale::getRegion($locale);
188 $variants = \Locale::getAllVariants($locale);
189
190 // Currently the only available variant is POSIX, which we don't want
191 // to include in the list
192 if (count($variants) > 0) {
193 return null;
194 }
195
196 // Some languages are translated together with their region,
197 // i.e. "en_GB" is translated as "British English"
198 // we don't include these languages though because they mess up
199 // the name sorting
200 // $name = $this->langBundle->getLanguageName($displayLocale, $lang, $region);
201
202 // Some languages are simply not translated
203 // Example: "az" (Azerbaijani) has no translation in "af" (Afrikaans)
204 if (null === ($name = $this->languageBundle->getLanguageName($lang, null, $displayLocale))) {
205 return null;
206 }
207
208 // "as" (Assamese) has no "Variants" block
209 //if (!$langBundle->get('Variants')) {
210 // continue;
211 //}
212
213 $extras = array();
214
215 // Discover the name of the script part of the locale
216 // i.e. in zh_Hans_MO, "Hans" is the script
217 if ($script) {
218 // Some scripts are not translated into every language
219 if (null === ($scriptName = $this->languageBundle->getScriptName($script, $lang, $displayLocale))) {
220 return null;
221 }
222
223 $extras[] = $scriptName;
224 }
225
226 // Discover the name of the region part of the locale
227 // i.e. in de_AT, "AT" is the region
228 if ($region) {
229 // Some regions are not translated into every language
230 if (null === ($regionName = $this->regionBundle->getCountryName($region, $displayLocale))) {
231 return null;
232 }
233
234 $extras[] = $regionName;
235 }
236
237 if (count($extras) > 0) {
238 // Remove any existing extras
239 // For example, in German, zh_Hans is "Chinesisch (vereinfacht)".
240 // The latter is the script part which is already included in the
241 // extras and will be appended again with the other extras.
242 if (preg_match('/^(.+)\s+\([^\)]+\)$/', $name, $matches)) {
243 $name = $matches[1];
244 }
245
246 $name .= ' ('.implode(', ', $extras).')';
247 }
248
249 return $name;
250 }
251}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/RegionBundleTransformationRule.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/RegionBundleTransformationRule.php
new file mode 100644
index 00000000..52fdbed8
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/RegionBundleTransformationRule.php
@@ -0,0 +1,70 @@
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\ResourceBundle\Transformer\Rule;
13
14use Symfony\Component\Intl\Intl;
15use Symfony\Component\Intl\ResourceBundle\Transformer\CompilationContextInterface;
16use Symfony\Component\Intl\ResourceBundle\Transformer\StubbingContextInterface;
17use Symfony\Component\Intl\Util\IcuVersion;
18
19/**
20 * The rule for compiling the region bundle.
21 *
22 * @author Bernhard Schussek <bschussek@gmail.com>
23 */
24class RegionBundleTransformationRule implements TransformationRuleInterface
25{
26 /**
27 * {@inheritdoc}
28 */
29 public function getBundleName()
30 {
31 return 'region';
32 }
33
34 /**
35 * {@inheritdoc}
36 */
37 public function beforeCompile(CompilationContextInterface $context)
38 {
39 // The region data is contained in the locales bundle in ICU <= 4.2
40 if (IcuVersion::compare($context->getIcuVersion(), '4.2', '<=', 1)) {
41 return $context->getSourceDir() . '/locales';
42 }
43
44 return $context->getSourceDir() . '/region';
45 }
46
47 /**
48 * {@inheritdoc}
49 */
50 public function afterCompile(CompilationContextInterface $context)
51 {
52 }
53
54 /**
55 * {@inheritdoc}
56 */
57 public function beforeCreateStub(StubbingContextInterface $context)
58 {
59 return array(
60 'Countries' => Intl::getRegionBundle()->getCountryNames('en'),
61 );
62 }
63
64 /**
65 * {@inheritdoc}
66 */
67 public function afterCreateStub(StubbingContextInterface $context)
68 {
69 }
70}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/TransformationRuleInterface.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/TransformationRuleInterface.php
new file mode 100644
index 00000000..3965e0d2
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/TransformationRuleInterface.php
@@ -0,0 +1,70 @@
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\ResourceBundle\Transformer\Rule;
13
14use Symfony\Component\Intl\ResourceBundle\Transformer\CompilationContextInterface;
15use Symfony\Component\Intl\ResourceBundle\Transformer\StubbingContextInterface;
16
17/**
18 * Contains instruction for compiling a resource bundle.
19 *
20 * @author Bernhard Schussek <bschussek@gmail.com>
21 */
22interface TransformationRuleInterface
23{
24 /**
25 * Returns the name of the compiled resource bundle.
26 *
27 * @return string The name of the bundle.
28 */
29 public function getBundleName();
30
31 /**
32 * Runs instructions to be executed before compiling the sources of the
33 * resource bundle.
34 *
35 * @param CompilationContextInterface $context The contextual information of
36 * the compilation.
37 *
38 * @return string[] The source directories/files of the bundle.
39 */
40 public function beforeCompile(CompilationContextInterface $context);
41
42 /**
43 * Runs instructions to be executed after compiling the sources of the
44 * resource bundle.
45 *
46 * @param CompilationContextInterface $context The contextual information of
47 * the compilation.
48 */
49 public function afterCompile(CompilationContextInterface $context);
50
51 /**
52 * Runs instructions to be executed before creating the stub version of the
53 * resource bundle.
54 *
55 * @param StubbingContextInterface $context The contextual information of
56 * the compilation.
57 *
58 * @return mixed The data to include in the stub version.
59 */
60 public function beforeCreateStub(StubbingContextInterface $context);
61
62 /**
63 * Runs instructions to be executed after creating the stub version of the
64 * resource bundle.
65 *
66 * @param StubbingContextInterface $context The contextual information of
67 * the compilation.
68 */
69 public function afterCreateStub(StubbingContextInterface $context);
70}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContext.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContext.php
new file mode 100644
index 00000000..25ab68db
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContext.php
@@ -0,0 +1,80 @@
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\ResourceBundle\Transformer;
13
14use Symfony\Component\Filesystem\Filesystem;
15
16/**
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class StubbingContext implements StubbingContextInterface
20{
21 /**
22 * @var string
23 */
24 private $binaryDir;
25
26 /**
27 * @var string
28 */
29 private $stubDir;
30
31 /**
32 * @var Filesystem
33 */
34 private $filesystem;
35
36 /**
37 * @var string
38 */
39 private $icuVersion;
40
41 public function __construct($binaryDir, $stubDir, Filesystem $filesystem, $icuVersion)
42 {
43 $this->binaryDir = $binaryDir;
44 $this->stubDir = $stubDir;
45 $this->filesystem = $filesystem;
46 $this->icuVersion = $icuVersion;
47 }
48
49 /**
50 * {@inheritdoc}
51 */
52 public function getBinaryDir()
53 {
54 return $this->binaryDir;
55 }
56
57 /**
58 * {@inheritdoc}
59 */
60 public function getStubDir()
61 {
62 return $this->stubDir;
63 }
64
65 /**
66 * {@inheritdoc}
67 */
68 public function getFilesystem()
69 {
70 return $this->filesystem;
71 }
72
73 /**
74 * {@inheritdoc}
75 */
76 public function getIcuVersion()
77 {
78 return $this->icuVersion;
79 }
80}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContextInterface.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContextInterface.php
new file mode 100644
index 00000000..dc492556
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContextInterface.php
@@ -0,0 +1,46 @@
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\ResourceBundle\Transformer;
13
14/**
15 * @author Bernhard Schussek <bschussek@gmail.com>
16 */
17interface StubbingContextInterface
18{
19 /**
20 * Returns the directory where the binary resource bundles are stored.
21 *
22 * @return string An absolute path to a directory.
23 */
24 public function getBinaryDir();
25
26 /**
27 * Returns the directory where the stub resource bundles are stored.
28 *
29 * @return string An absolute path to a directory.
30 */
31 public function getStubDir();
32
33 /**
34 * Returns a tool for manipulating the filesystem.
35 *
36 * @return \Symfony\Component\Filesystem\Filesystem The filesystem manipulator.
37 */
38 public function getFilesystem();
39
40 /**
41 * Returns the ICU version of the bundles being converted.
42 *
43 * @return string The ICU version string.
44 */
45 public function getIcuVersion();
46}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Util/ArrayAccessibleResourceBundle.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Util/ArrayAccessibleResourceBundle.php
new file mode 100644
index 00000000..9a4cccb4
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Util/ArrayAccessibleResourceBundle.php
@@ -0,0 +1,79 @@
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\ResourceBundle\Util;
13
14use Symfony\Component\Intl\Exception\BadMethodCallException;
15
16/**
17 * Work-around for a bug in PHP's \ResourceBundle implementation.
18 *
19 * More information can be found on https://bugs.php.net/bug.php?id=64356.
20 * This class can be removed once that bug is fixed.
21 *
22 * @author Bernhard Schussek <bschussek@gmail.com>
23 */
24class ArrayAccessibleResourceBundle implements \ArrayAccess, \IteratorAggregate, \Countable
25{
26 private $bundleImpl;
27
28 public function __construct(\ResourceBundle $bundleImpl)
29 {
30 $this->bundleImpl = $bundleImpl;
31 }
32
33 public function get($offset, $fallback = null)
34 {
35 $value = $this->bundleImpl->get($offset, $fallback);
36
37 return $value instanceof \ResourceBundle ? new static($value) : $value;
38 }
39
40 public function offsetExists($offset)
41 {
42 return null !== $this->bundleImpl[$offset];
43 }
44
45 public function offsetGet($offset)
46 {
47 return $this->get($offset);
48 }
49
50 public function offsetSet($offset, $value)
51 {
52 throw new BadMethodCallException('Resource bundles cannot be modified.');
53 }
54
55 public function offsetUnset($offset)
56 {
57 throw new BadMethodCallException('Resource bundles cannot be modified.');
58 }
59
60 public function getIterator()
61 {
62 return $this->bundleImpl;
63 }
64
65 public function count()
66 {
67 return $this->bundleImpl->count();
68 }
69
70 public function getErrorCode()
71 {
72 return $this->bundleImpl->getErrorCode();
73 }
74
75 public function getErrorMessage()
76 {
77 return $this->bundleImpl->getErrorMessage();
78 }
79}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Util/RecursiveArrayAccess.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Util/RecursiveArrayAccess.php
new file mode 100644
index 00000000..e1feaa2c
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Util/RecursiveArrayAccess.php
@@ -0,0 +1,33 @@
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\ResourceBundle\Util;
13
14/**
15 * @author Bernhard Schussek <bschussek@gmail.com>
16 */
17class RecursiveArrayAccess
18{
19 public static function get($array, array $indices)
20 {
21 foreach ($indices as $index) {
22 if (!$array instanceof \ArrayAccess && !is_array($array)) {
23 return null;
24 }
25
26 $array = $array[$index];
27 }
28
29 return $array;
30 }
31
32 private function __construct() {}
33}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Util/RingBuffer.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Util/RingBuffer.php
new file mode 100644
index 00000000..7ccbd1e7
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Util/RingBuffer.php
@@ -0,0 +1,88 @@
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\ResourceBundle\Util;
13
14use Symfony\Component\Intl\Exception\OutOfBoundsException;
15
16/**
17 * Implements a ring buffer.
18 *
19 * A ring buffer is an array-like structure with a fixed size. If the buffer
20 * is full, the next written element overwrites the first bucket in the buffer,
21 * then the second and so on.
22 *
23 * @author Bernhard Schussek <bschussek@gmail.com>
24 */
25class RingBuffer implements \ArrayAccess
26{
27 private $values = array();
28
29 private $indices = array();
30
31 private $cursor = 0;
32
33 private $size;
34
35 public function __construct($size)
36 {
37 $this->size = $size;
38 }
39
40 /**
41 * {@inheritdoc}
42 */
43 public function offsetExists($key)
44 {
45 return isset($this->indices[$key]);
46 }
47
48 /**
49 * {@inheritdoc}
50 */
51 public function offsetGet($key)
52 {
53 if (!isset($this->indices[$key])) {
54 throw new OutOfBoundsException(sprintf(
55 'The index "%s" does not exist.',
56 $key
57 ));
58 }
59
60 return $this->values[$this->indices[$key]];
61 }
62
63 /**
64 * {@inheritdoc}
65 */
66 public function offsetSet($key, $value)
67 {
68 if (false !== ($keyToRemove = array_search($this->cursor, $this->indices))) {
69 unset($this->indices[$keyToRemove]);
70 }
71
72 $this->values[$this->cursor] = $value;
73 $this->indices[$key] = $this->cursor;
74
75 $this->cursor = ($this->cursor + 1) % $this->size;
76 }
77
78 /**
79 * {@inheritdoc}
80 */
81 public function offsetUnset($key)
82 {
83 if (isset($this->indices[$key])) {
84 $this->values[$this->indices[$key]] = null;
85 unset($this->indices[$key]);
86 }
87 }
88}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Writer/BundleWriterInterface.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Writer/BundleWriterInterface.php
new file mode 100644
index 00000000..cc3b9586
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Writer/BundleWriterInterface.php
@@ -0,0 +1,29 @@
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\ResourceBundle\Writer;
13
14/**
15 * Writes resource bundle files.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19interface BundleWriterInterface
20{
21 /**
22 * Writes data to a resource bundle.
23 *
24 * @param string $path The path to the resource bundle.
25 * @param string $locale The locale to (over-)write.
26 * @param mixed $data The data to write.
27 */
28 public function write($path, $locale, $data);
29}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Writer/PhpBundleWriter.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Writer/PhpBundleWriter.php
new file mode 100644
index 00000000..d2688b49
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Writer/PhpBundleWriter.php
@@ -0,0 +1,50 @@
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\ResourceBundle\Writer;
13
14/**
15 * Writes .php resource bundles.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class PhpBundleWriter implements BundleWriterInterface
20{
21 /**
22 * {@inheritdoc}
23 */
24 public function write($path, $locale, $data)
25 {
26 $template = <<<TEMPLATE
27<?php
28
29/*
30 * This file is part of the Symfony package.
31 *
32 * (c) Fabien Potencier <fabien@symfony.com>
33 *
34 * For the full copyright and license information, please view the LICENSE
35 * file that was distributed with this source code.
36 */
37
38return %s;
39
40TEMPLATE;
41
42 $data = var_export($data, true);
43 $data = preg_replace('/array \(/', 'array(', $data);
44 $data = preg_replace('/\n {1,10}array\(/', 'array(', $data);
45 $data = preg_replace('/ /', ' ', $data);
46 $data = sprintf($template, $data);
47
48 file_put_contents($path.'/'.$locale.'.php', $data);
49 }
50}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Writer/TextBundleWriter.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Writer/TextBundleWriter.php
new file mode 100644
index 00000000..342ee2dc
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Writer/TextBundleWriter.php
@@ -0,0 +1,202 @@
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\ResourceBundle\Writer;
13
14/**
15 * Writes .txt resource bundles.
16 *
17 * The resulting files can be converted to binary .res files using the
18 * {@link \Symfony\Component\Intl\ResourceBundle\Transformer\BundleCompiler}.
19 *
20 * @author Bernhard Schussek <bschussek@gmail.com>
21 *
22 * @see http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt
23 */
24class TextBundleWriter implements BundleWriterInterface
25{
26 /**
27 * {@inheritdoc}
28 */
29 public function write($path, $locale, $data)
30 {
31 $file = fopen($path.'/'.$locale.'.txt', 'w');
32
33 $this->writeResourceBundle($file, $locale, $data);
34
35 fclose($file);
36 }
37
38 /**
39 * Writes a "resourceBundle" node.
40 *
41 * @param resource $file The file handle to write to.
42 * @param string $bundleName The name of the bundle.
43 * @param mixed $value The value of the node.
44 *
45 * @see http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt
46 */
47 private function writeResourceBundle($file, $bundleName, $value)
48 {
49 fwrite($file, $bundleName);
50
51 $this->writeTable($file, $value, 0);
52
53 fwrite($file, "\n");
54 }
55
56 /**
57 * Writes a "resource" node.
58 *
59 * @param resource $file The file handle to write to.
60 * @param mixed $value The value of the node.
61 * @param integer $indentation The number of levels to indent.
62 * @param Boolean $requireBraces Whether to require braces to be printed
63 * around the value.
64 *
65 * @see http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt
66 */
67 private function writeResource($file, $value, $indentation, $requireBraces = true)
68 {
69 if (is_int($value)) {
70 $this->writeInteger($file, $value);
71
72 return;
73 }
74
75 if (is_array($value)) {
76 if (count($value) === count(array_filter($value, 'is_int'))) {
77 $this->writeIntVector($file, $value, $indentation);
78
79 return;
80 }
81
82 $keys = array_keys($value);
83
84 if (count($keys) === count(array_filter($keys, 'is_int'))) {
85 $this->writeArray($file, $value, $indentation);
86
87 return;
88 }
89
90 $this->writeTable($file, $value, $indentation);
91
92 return;
93 }
94
95 if (is_bool($value)) {
96 $value = $value ? 'true' : 'false';
97 }
98
99 $this->writeString($file, (string) $value, $requireBraces);
100 }
101
102 /**
103 * Writes an "integer" node.
104 *
105 * @param resource $file The file handle to write to.
106 * @param integer $value The value of the node.
107 *
108 * @see http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt
109 */
110 private function writeInteger($file, $value)
111 {
112 fprintf($file, ':int{%d}', $value);
113 }
114
115 /**
116 * Writes an "intvector" node.
117 *
118 * @param resource $file The file handle to write to.
119 * @param array $value The value of the node.
120 * @param integer $indentation The number of levels to indent.
121 *
122 * @see http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt
123 */
124 private function writeIntVector($file, array $value, $indentation)
125 {
126 fwrite($file, ":intvector{\n");
127
128 foreach ($value as $int) {
129 fprintf($file, "%s%d,\n", str_repeat(' ', $indentation + 1), $int);
130 }
131
132 fprintf($file, "%s}", str_repeat(' ', $indentation));
133 }
134
135 /**
136 * Writes a "string" node.
137 *
138 * @param resource $file The file handle to write to.
139 * @param string $value The value of the node.
140 * @param Boolean $requireBraces Whether to require braces to be printed
141 * around the value.
142 *
143 * @see http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt
144 */
145 private function writeString($file, $value, $requireBraces = true)
146 {
147 if ($requireBraces) {
148 fprintf($file, '{"%s"}', $value);
149
150 return;
151 }
152
153 fprintf($file, '"%s"', $value);
154 }
155
156 /**
157 * Writes an "array" node.
158 *
159 * @param resource $file The file handle to write to.
160 * @param array $value The value of the node.
161 * @param integer $indentation The number of levels to indent.
162 *
163 * @see http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt
164 */
165 private function writeArray($file, array $value, $indentation)
166 {
167 fwrite($file, "{\n");
168
169 foreach ($value as $entry) {
170 fwrite($file, str_repeat(' ', $indentation + 1));
171
172 $this->writeResource($file, $entry, $indentation + 1, false);
173
174 fwrite($file, ",\n");
175 }
176
177 fprintf($file, '%s}', str_repeat(' ', $indentation));
178 }
179
180 /**
181 * Writes a "table" node.
182 *
183 * @param resource $file The file handle to write to.
184 * @param array $value The value of the node.
185 * @param integer $indentation The number of levels to indent.
186 */
187 private function writeTable($file, array $value, $indentation)
188 {
189 fwrite($file, "{\n");
190
191 foreach ($value as $key => $entry) {
192 fwrite($file, str_repeat(' ', $indentation + 1));
193 fwrite($file, $key);
194
195 $this->writeResource($file, $entry, $indentation + 1);
196
197 fwrite($file, "\n");
198 }
199
200 fprintf($file, '%s}', str_repeat(' ', $indentation));
201 }
202}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/autoload.php b/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/autoload.php
new file mode 100644
index 00000000..e4500115
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/autoload.php
@@ -0,0 +1,18 @@
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
12$autoload = __DIR__ . '/../../vendor/autoload.php';
13
14if (!file_exists($autoload)) {
15 bailout('You should run "composer install --dev" in the component before running this script.');
16}
17
18require_once realpath($autoload);
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/common.php b/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/common.php
new file mode 100644
index 00000000..4fadbe82
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/common.php
@@ -0,0 +1,69 @@
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
12define('LINE_WIDTH', 75);
13
14define('LINE', str_repeat('-', LINE_WIDTH) . "\n");
15
16function bailout($message)
17{
18 echo wordwrap($message, LINE_WIDTH) . " Aborting.\n";
19
20 exit(1);
21}
22
23function strip_minor_versions($version)
24{
25 preg_match('/^(?P<version>[0-9]\.[0-9]|[0-9]{2,})/', $version, $matches);
26
27 return $matches['version'];
28}
29
30function centered($text)
31{
32 $padding = (int) ((LINE_WIDTH - strlen($text))/2);
33
34 return str_repeat(' ', $padding) . $text;
35}
36
37function cd($dir)
38{
39 if (false === chdir($dir)) {
40 bailout("Could not switch to directory $dir.");
41 }
42}
43
44function run($command)
45{
46 exec($command, $output, $status);
47
48 if (0 !== $status) {
49 $output = implode("\n", $output);
50 echo "Error while running:\n " . getcwd() . '$ ' . $command . "\nOutput:\n" . LINE . "$output\n" . LINE;
51
52 bailout("\"$command\" failed.");
53 }
54}
55
56function get_icu_version_from_genrb($genrb)
57{
58 exec($genrb . ' --version 2>&1', $output, $status);
59
60 if (0 !== $status) {
61 bailout($genrb . ' failed.');
62 }
63
64 if (!preg_match('/ICU version ([\d\.]+)/', implode('', $output), $matches)) {
65 return null;
66 }
67
68 return $matches[1];
69}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/copy-stubs-to-component.php b/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/copy-stubs-to-component.php
new file mode 100644
index 00000000..e8576832
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/copy-stubs-to-component.php
@@ -0,0 +1,63 @@
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
12use Symfony\Component\Filesystem\Filesystem;
13use Symfony\Component\Icu\IcuData;
14use Symfony\Component\Intl\Intl;
15
16require_once __DIR__ . '/common.php';
17require_once __DIR__ . '/autoload.php';
18
19if (1 !== $GLOBALS['argc']) {
20 bailout(<<<MESSAGE
21Usage: php copy-stubs-to-component.php
22
23Copies stub files created with create-stubs.php to the Icu component.
24
25For running this script, the intl extension must be loaded and all vendors
26must have been installed through composer:
27
28 composer install --dev
29
30MESSAGE
31 );
32}
33
34echo LINE;
35echo centered("ICU Resource Bundle Stub Update") . "\n";
36echo LINE;
37
38if (!class_exists('\Symfony\Component\Icu\IcuData')) {
39 bailout('You must run "composer update --dev" before running this script.');
40}
41
42$stubBranch = '1.0.x';
43
44if (!IcuData::isStubbed()) {
45 bailout("Please switch to the Icu component branch $stubBranch.");
46}
47
48$filesystem = new Filesystem();
49
50$sourceDir = sys_get_temp_dir() . '/icu-stubs';
51$targetDir = IcuData::getResourceDirectory();
52
53if (!$filesystem->exists($sourceDir)) {
54 bailout("The directory $sourceDir does not exist. Please run create-stubs.php first.");
55}
56
57$filesystem->remove($targetDir);
58
59echo "Copying files from $sourceDir to $targetDir...\n";
60
61$filesystem->mirror($sourceDir, $targetDir);
62
63echo "Done.\n";
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/create-stubs.php b/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/create-stubs.php
new file mode 100644
index 00000000..d330d6b5
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/create-stubs.php
@@ -0,0 +1,112 @@
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
12use Symfony\Component\Filesystem\Filesystem;
13use Symfony\Component\Icu\IcuData;
14use Symfony\Component\Intl\Intl;
15use Symfony\Component\Intl\ResourceBundle\Transformer\BundleTransformer;
16use Symfony\Component\Intl\ResourceBundle\Transformer\Rule\CurrencyBundleTransformationRule;
17use Symfony\Component\Intl\ResourceBundle\Transformer\Rule\LanguageBundleTransformationRule;
18use Symfony\Component\Intl\ResourceBundle\Transformer\Rule\LocaleBundleTransformationRule;
19use Symfony\Component\Intl\ResourceBundle\Transformer\Rule\RegionBundleTransformationRule;
20use Symfony\Component\Intl\ResourceBundle\Transformer\StubbingContext;
21
22require_once __DIR__ . '/common.php';
23require_once __DIR__ . '/autoload.php';
24
25if (1 !== $GLOBALS['argc']) {
26 bailout(<<<MESSAGE
27Usage: php create-stubs.php
28
29Creates resource bundle stubs from the resource bundles in the Icu component.
30
31For running this script, the intl extension must be loaded and all vendors
32must have been installed through composer:
33
34 composer install --dev
35
36MESSAGE
37 );
38}
39
40echo LINE;
41echo centered("ICU Resource Bundle Stub Creation") . "\n";
42echo LINE;
43
44if (!Intl::isExtensionLoaded()) {
45 bailout('The intl extension for PHP is not installed.');
46}
47
48if (!class_exists('\Symfony\Component\Icu\IcuData')) {
49 bailout('You must run "composer update --dev" before running this script.');
50}
51
52$stubBranch = '1.0.x';
53
54if (IcuData::isStubbed()) {
55 bailout("Please switch to a branch of the Icu component that contains .res files (anything but $stubBranch).");
56}
57
58$shortIcuVersionInPhp = strip_minor_versions(Intl::getIcuVersion());
59$shortIcuVersionInIntlComponent = strip_minor_versions(Intl::getIcuStubVersion());
60$shortIcuVersionInIcuComponent = strip_minor_versions(IcuData::getVersion());
61
62if ($shortIcuVersionInPhp !== $shortIcuVersionInIcuComponent) {
63 bailout("The ICU version of the component ($shortIcuVersionInIcuComponent) does not match the ICU version in the intl extension ($shortIcuVersionInPhp).");
64}
65
66if ($shortIcuVersionInIntlComponent !== $shortIcuVersionInIcuComponent) {
67 bailout("The ICU version of the component ($shortIcuVersionInIcuComponent) does not match the ICU version of the stub classes in the Intl component ($shortIcuVersionInIntlComponent).");
68}
69
70echo wordwrap("Make sure that you don't have any ICU development files " .
71 "installed. If the build fails, try to run:\n", LINE_WIDTH);
72
73echo "\n sudo apt-get remove libicu-dev\n\n";
74
75$icuVersionInIcuComponent = IcuData::getVersion();
76
77echo "Compiling stubs for ICU version $icuVersionInIcuComponent.\n";
78
79echo "Preparing stub creation...\n";
80
81$targetDir = sys_get_temp_dir() . '/icu-stubs';
82
83$context = new StubbingContext(
84 IcuData::getResourceDirectory(),
85 $targetDir,
86 new Filesystem(),
87 $icuVersionInIcuComponent
88);
89
90$transformer = new BundleTransformer();
91$transformer->addRule(new LanguageBundleTransformationRule());
92$transformer->addRule(new RegionBundleTransformationRule());
93$transformer->addRule(new CurrencyBundleTransformationRule());
94$transformer->addRule(new LocaleBundleTransformationRule());
95
96echo "Starting stub creation...\n";
97
98$transformer->createStubs($context);
99
100echo "Wrote stubs to $targetDir.\n";
101
102$versionFile = $context->getStubDir() . '/version.txt';
103
104file_put_contents($versionFile, "$icuVersionInIcuComponent\n");
105
106echo "Wrote $versionFile.\n";
107
108echo "Done.\n";
109
110echo wordwrap("Please change the Icu component to branch $stubBranch now and run:\n", LINE_WIDTH);
111
112echo "\n php copy-stubs-to-component.php\n";
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/icu-version.php b/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/icu-version.php
new file mode 100644
index 00000000..d54916f5
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/icu-version.php
@@ -0,0 +1,18 @@
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
12use Symfony\Component\Intl\Intl;
13
14require_once __DIR__ . '/common.php';
15require_once __DIR__ . '/autoload.php';
16
17echo "ICU version: ";
18echo Intl::getIcuVersion() . "\n";
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/icu.ini b/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/icu.ini
new file mode 100644
index 00000000..902e3361
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/icu.ini
@@ -0,0 +1,9 @@
1; ICU data source URLs
2; We use always the latest release of a major version.
34.0 = http://source.icu-project.org/repos/icu/icu/tags/release-4-0-1/source
44.2 = http://source.icu-project.org/repos/icu/icu/tags/release-4-2-1/source
54.4 = http://source.icu-project.org/repos/icu/icu/tags/release-4-4-2/source
64.6 = http://source.icu-project.org/repos/icu/icu/tags/release-4-6-1/source
74.8 = http://source.icu-project.org/repos/icu/icu/tags/release-4-8-1-1/source
849 = http://source.icu-project.org/repos/icu/icu/tags/release-49-1-2/source
950 = http://source.icu-project.org/repos/icu/icu/tags/release-50-1-2/source
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/test-compat.php b/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/test-compat.php
new file mode 100644
index 00000000..c1bf40f7
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/test-compat.php
@@ -0,0 +1,56 @@
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
12use Symfony\Component\Intl\Intl;
13
14require_once __DIR__ . '/common.php';
15require_once __DIR__ . '/autoload.php';
16
17if (1 !== $GLOBALS['argc']) {
18 bailout(<<<MESSAGE
19Usage: php test-compat.php
20
21Tests the compatibility of the current ICU version (bundled in ext/intl) with
22different versions of symfony/icu.
23
24For running this script, the intl extension must be loaded and all vendors
25must have been installed through composer:
26
27 composer install --dev
28
29MESSAGE
30 );
31}
32
33echo LINE;
34echo centered("ICU Compatibility Test") . "\n";
35echo LINE;
36
37echo "Your ICU version: " . Intl::getIcuVersion() . "\n";
38
39echo "Compatibility with symfony/icu:\n";
40
41$branches = array(
42 '1.1.x',
43 '1.2.x',
44);
45
46cd(__DIR__ . '/../../vendor/symfony/icu/Symfony/Component/Icu');
47
48foreach ($branches as $branch) {
49 run('git checkout ' . $branch . ' 2>&1');
50
51 exec('php ' . __DIR__ . '/util/test-compat-helper.php > /dev/null 2> /dev/null', $output, $status);
52
53 echo "$branch: " . (0 === $status ? "YES" : "NO") . "\n";
54}
55
56echo "Done.\n";
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/update-icu-component.php b/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/update-icu-component.php
new file mode 100644
index 00000000..2b94fe41
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/update-icu-component.php
@@ -0,0 +1,212 @@
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
12use Symfony\Component\Icu\IcuData;
13use Symfony\Component\Intl\Intl;
14use Symfony\Component\Intl\ResourceBundle\Compiler\BundleCompiler;
15use Symfony\Component\Intl\ResourceBundle\Transformer\BundleTransformer;
16use Symfony\Component\Intl\ResourceBundle\Transformer\CompilationContext;
17use Symfony\Component\Intl\ResourceBundle\Transformer\Rule\CurrencyBundleTransformationRule;
18use Symfony\Component\Intl\ResourceBundle\Transformer\Rule\LanguageBundleTransformationRule;
19use Symfony\Component\Intl\ResourceBundle\Transformer\Rule\LocaleBundleTransformationRule;
20use Symfony\Component\Intl\ResourceBundle\Transformer\Rule\RegionBundleTransformationRule;
21use Symfony\Component\Intl\Util\SvnRepository;
22use Symfony\Component\Filesystem\Filesystem;
23
24require_once __DIR__ . '/common.php';
25require_once __DIR__ . '/autoload.php';
26
27if ($GLOBALS['argc'] > 3 || 2 === $GLOBALS['argc'] && '-h' === $GLOBALS['argv'][1]) {
28 bailout(<<<MESSAGE
29Usage: php update-icu-component.php <path/to/icu/source> <path/to/icu/build>
30
31Updates the ICU data for Symfony2 to the latest version of the ICU version
32included in the intl extension. For example, if your intl extension includes
33ICU 4.8, the script will download the latest data available for ICU 4.8.
34
35If you downloaded the SVN repository before, you can pass the path to the
36repository source in the first optional argument.
37
38If you also built the repository before, you can pass the directory where that
39build is stored in the second parameter. The build directory needs to contain
40the subdirectories bin/ and lib/.
41
42For running this script, the intl extension must be loaded and all vendors
43must have been installed through composer:
44
45 composer install --dev
46
47MESSAGE
48 );
49}
50
51echo LINE;
52echo centered("ICU Resource Bundle Compilation") . "\n";
53echo LINE;
54
55if (!Intl::isExtensionLoaded()) {
56 bailout('The intl extension for PHP is not installed.');
57}
58
59if (!class_exists('\Symfony\Component\Icu\IcuData')) {
60 bailout('You must run "composer update --dev" before running this script.');
61}
62
63$filesystem = new Filesystem();
64
65$icuVersionInPhp = Intl::getIcuVersion();
66
67echo "Found intl extension with ICU version $icuVersionInPhp.\n";
68
69$shortIcuVersion = strip_minor_versions($icuVersionInPhp);
70$urls = parse_ini_file(__DIR__ . '/icu.ini');
71
72if (!isset($urls[$shortIcuVersion])) {
73 bailout('The version ' . $shortIcuVersion . ' is not available in the icu.ini file.');
74}
75
76echo "icu.ini parsed. Available versions:\n";
77
78foreach ($urls as $urlVersion => $url) {
79 echo " $urlVersion\n";
80}
81
82if ($GLOBALS['argc'] >= 2) {
83 $sourceDir = $GLOBALS['argv'][1];
84 $svn = new SvnRepository($sourceDir);
85
86 echo "Using existing SVN repository at {$sourceDir}.\n";
87} else {
88 echo "Starting SVN checkout for version $shortIcuVersion. This may take a while...\n";
89
90 $sourceDir = sys_get_temp_dir() . '/icu-data/' . $shortIcuVersion . '/source';
91 $svn = SvnRepository::download($urls[$shortIcuVersion], $sourceDir);
92
93 echo "SVN checkout to {$sourceDir} complete.\n";
94}
95
96if ($GLOBALS['argc'] >= 3) {
97 $buildDir = $GLOBALS['argv'][2];
98} else {
99 // Always build genrb so that we can determine the ICU version of the
100 // download by running genrb --version
101 echo "Building genrb.\n";
102
103 cd($sourceDir);
104
105 echo "Running configure...\n";
106
107 $buildDir = sys_get_temp_dir() . '/icu-data/' . $shortIcuVersion . '/build';
108
109 $filesystem->remove($buildDir);
110 $filesystem->mkdir($buildDir);
111
112 run('./configure --prefix=' . $buildDir . ' 2>&1');
113
114 echo "Running make...\n";
115
116 // If the directory "lib" does not exist in the download, create it or we
117 // will run into problems when building libicuuc.so.
118 $filesystem->mkdir($sourceDir . '/lib');
119
120 // If the directory "bin" does not exist in the download, create it or we
121 // will run into problems when building genrb.
122 $filesystem->mkdir($sourceDir . '/bin');
123
124 echo "[1/5] libicudata.so...";
125
126 cd($sourceDir . '/stubdata');
127 run('make 2>&1 && make install 2>&1');
128
129 echo " ok.\n";
130
131 echo "[2/5] libicuuc.so...";
132
133 cd($sourceDir . '/common');
134 run('make 2>&1 && make install 2>&1');
135
136 echo " ok.\n";
137
138 echo "[3/5] libicui18n.so...";
139
140 cd($sourceDir . '/i18n');
141 run('make 2>&1 && make install 2>&1');
142
143 echo " ok.\n";
144
145 echo "[4/5] libicutu.so...";
146
147 cd($sourceDir . '/tools/toolutil');
148 run('make 2>&1 && make install 2>&1');
149
150 echo " ok.\n";
151
152 echo "[5/5] genrb...";
153
154 cd($sourceDir . '/tools/genrb');
155 run('make 2>&1 && make install 2>&1');
156
157 echo " ok.\n";
158}
159
160$genrb = $buildDir . '/bin/genrb';
161$genrbEnv = 'LD_LIBRARY_PATH=' . $buildDir . '/lib ';
162
163echo "Using $genrb.\n";
164
165$icuVersionInDownload = get_icu_version_from_genrb($genrbEnv . ' ' . $genrb);
166
167echo "Preparing resource bundle compilation (version $icuVersionInDownload)...\n";
168
169$context = new CompilationContext(
170 $sourceDir . '/data',
171 IcuData::getResourceDirectory(),
172 $filesystem,
173 new BundleCompiler($genrb, $genrbEnv),
174 $icuVersionInDownload
175);
176
177$transformer = new BundleTransformer();
178$transformer->addRule(new LanguageBundleTransformationRule());
179$transformer->addRule(new RegionBundleTransformationRule());
180$transformer->addRule(new CurrencyBundleTransformationRule());
181$transformer->addRule(new LocaleBundleTransformationRule());
182
183echo "Starting resource bundle compilation. This may take a while...\n";
184
185$transformer->compileBundles($context);
186
187echo "Resource bundle compilation complete.\n";
188
189$svnInfo = <<<SVN_INFO
190SVN information
191===============
192
193URL: {$svn->getUrl()}
194Revision: {$svn->getLastCommit()->getRevision()}
195Author: {$svn->getLastCommit()->getAuthor()}
196Date: {$svn->getLastCommit()->getDate()}
197
198SVN_INFO;
199
200$svnInfoFile = $context->getBinaryDir() . '/svn-info.txt';
201
202file_put_contents($svnInfoFile, $svnInfo);
203
204echo "Wrote $svnInfoFile.\n";
205
206$versionFile = $context->getBinaryDir() . '/version.txt';
207
208file_put_contents($versionFile, "$icuVersionInDownload\n");
209
210echo "Wrote $versionFile.\n";
211
212echo "Done.\n";
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/util/test-compat-helper.php b/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/util/test-compat-helper.php
new file mode 100644
index 00000000..2734895c
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Resources/bin/util/test-compat-helper.php
@@ -0,0 +1,23 @@
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
12use Symfony\Component\Icu\IcuData;
13use Symfony\Component\Intl\ResourceBundle\Reader\BinaryBundleReader;
14
15require_once __DIR__ . '/../common.php';
16require_once __DIR__ . '/../autoload.php';
17
18$reader = new BinaryBundleReader();
19
20$reader->read(IcuData::getResourceDirectory() . '/curr', 'en');
21$reader->read(IcuData::getResourceDirectory() . '/lang', 'en');
22$reader->read(IcuData::getResourceDirectory() . '/locales', 'en');
23$reader->read(IcuData::getResourceDirectory() . '/region', 'en');
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Resources/stubs/Collator.php b/vendor/symfony/intl/Symfony/Component/Intl/Resources/stubs/Collator.php
new file mode 100644
index 00000000..4c373d86
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Resources/stubs/Collator.php
@@ -0,0 +1,21 @@
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
12/**
13 * Stub implementation for the Collator class of the intl extension
14 *
15 * @author Bernhard Schussek <bschussek@gmail.com>
16 *
17 * @see \Symfony\Component\Intl\Collator\StubCollator
18 */
19class Collator extends \Symfony\Component\Intl\Collator\Collator
20{
21}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Resources/stubs/IntlDateFormatter.php b/vendor/symfony/intl/Symfony/Component/Intl/Resources/stubs/IntlDateFormatter.php
new file mode 100644
index 00000000..52a07e95
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Resources/stubs/IntlDateFormatter.php
@@ -0,0 +1,21 @@
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
12/**
13 * Stub implementation for the IntlDateFormatter class of the intl extension
14 *
15 * @author Bernhard Schussek <bschussek@gmail.com>
16 *
17 * @see \Symfony\Component\Intl\DateFormatter\IntlDateFormatter
18 */
19class IntlDateFormatter extends \Symfony\Component\Intl\DateFormatter\IntlDateFormatter
20{
21}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Resources/stubs/Locale.php b/vendor/symfony/intl/Symfony/Component/Intl/Resources/stubs/Locale.php
new file mode 100644
index 00000000..045db40c
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Resources/stubs/Locale.php
@@ -0,0 +1,21 @@
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
12/**
13 * Stub implementation for the Locale class of the intl extension
14 *
15 * @author Bernhard Schussek <bschussek@gmail.com>
16 *
17 * @see \Symfony\Component\Intl\Locale\Locale
18 */
19class Locale extends \Symfony\Component\Intl\Locale\Locale
20{
21}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Resources/stubs/NumberFormatter.php b/vendor/symfony/intl/Symfony/Component/Intl/Resources/stubs/NumberFormatter.php
new file mode 100644
index 00000000..318efb49
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Resources/stubs/NumberFormatter.php
@@ -0,0 +1,21 @@
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
12/**
13 * Stub implementation for the NumberFormatter class of the intl extension
14 *
15 * @author Bernhard Schussek <bschussek@gmail.com>
16 *
17 * @see \Symfony\Component\Intl\NumberFormatter\NumberFormatter
18 */
19class NumberFormatter extends \Symfony\Component\Intl\NumberFormatter\NumberFormatter
20{
21}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Resources/stubs/functions.php b/vendor/symfony/intl/Symfony/Component/Intl/Resources/stubs/functions.php
new file mode 100644
index 00000000..7a2d4b67
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Resources/stubs/functions.php
@@ -0,0 +1,80 @@
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
12use Symfony\Component\Intl\Globals\IntlGlobals;
13
14if (!function_exists('intl_is_failure')) {
15
16 /**
17 * Stub implementation for the {@link intl_is_failure()} function of the intl
18 * extension.
19 *
20 * @author Bernhard Schussek <bschussek@gmail.com>
21 *
22 * @param integer $errorCode The error code returned by intl_get_error_code().
23 *
24 * @return Boolean Whether the error code indicates an error.
25 *
26 * @see \Symfony\Component\Intl\Globals\StubIntlGlobals::isFailure
27 */
28 function intl_is_failure($errorCode)
29 {
30 return IntlGlobals::isFailure($errorCode);
31 }
32
33 /**
34 * Stub implementation for the {@link intl_get_error_code()} function of the
35 * intl extension.
36 *
37 * @author Bernhard Schussek <bschussek@gmail.com>
38 *
39 * @return Boolean The error code of the last intl function call or
40 * IntlGlobals::U_ZERO_ERROR if no error occurred.
41 *
42 * @see \Symfony\Component\Intl\Globals\StubIntlGlobals::getErrorCode
43 */
44 function intl_get_error_code()
45 {
46 return IntlGlobals::getErrorCode();
47 }
48
49 /**
50 * Stub implementation for the {@link intl_get_error_code()} function of the
51 * intl extension.
52 *
53 * @author Bernhard Schussek <bschussek@gmail.com>
54 *
55 * @return Boolean The error message of the last intl function call or
56 * "U_ZERO_ERROR" if no error occurred.
57 *
58 * @see \Symfony\Component\Intl\Globals\StubIntlGlobals::getErrorMessage
59 */
60 function intl_get_error_message()
61 {
62 return IntlGlobals::getErrorMessage();
63 }
64
65 /**
66 * Stub implementation for the {@link intl_error_name()} function of the intl
67 * extension.
68 *
69 * @param integer $errorCode The error code.
70 *
71 * @return string The name of the error code constant.
72 *
73 * @see \Symfony\Component\Intl\Globals\StubIntlGlobals::getErrorName
74 */
75 function intl_error_name($errorCode)
76 {
77 return IntlGlobals::getErrorName($errorCode);
78 }
79
80}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/AbstractCollatorTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/AbstractCollatorTest.php
new file mode 100644
index 00000000..08f3a566
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/AbstractCollatorTest.php
@@ -0,0 +1,62 @@
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\Tests\Collator;
13
14use Symfony\Component\Intl\Collator\Collator;
15use Symfony\Component\Intl\Locale;
16
17/**
18 * Test case for Collator implementations.
19 *
20 * @author Bernhard Schussek <bschussek@gmail.com>
21 */
22abstract class AbstractCollatorTest extends \PHPUnit_Framework_TestCase
23{
24 /**
25 * @dataProvider asortProvider
26 */
27 public function testAsort($array, $sortFlag, $expected)
28 {
29 $collator = $this->getCollator('en');
30 $collator->asort($array, $sortFlag);
31 $this->assertSame($expected, $array);
32 }
33
34 public function asortProvider()
35 {
36 return array(
37 /* array, sortFlag, expected */
38 array(
39 array('a', 'b', 'c'),
40 Collator::SORT_REGULAR,
41 array('a', 'b', 'c'),
42 ),
43 array(
44 array('c', 'b', 'a'),
45 Collator::SORT_REGULAR,
46 array(2 => 'a', 1 => 'b', 0 => 'c'),
47 ),
48 array(
49 array('b', 'c', 'a'),
50 Collator::SORT_REGULAR,
51 array(2 => 'a', 0 => 'b', 1 => 'c'),
52 ),
53 );
54 }
55
56 /**
57 * @param string $locale
58 *
59 * @return \Collator
60 */
61 abstract protected function getCollator($locale);
62}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/CollatorTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/CollatorTest.php
new file mode 100644
index 00000000..a4e4e56b
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/CollatorTest.php
@@ -0,0 +1,109 @@
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\Tests\Collator;
13
14use Symfony\Component\Intl\Collator\Collator;
15use Symfony\Component\Intl\Globals\IntlGlobals;
16
17class CollatorTest extends AbstractCollatorTest
18{
19 /**
20 * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
21 */
22 public function testConstructorWithUnsupportedLocale()
23 {
24 new Collator('pt_BR');
25 }
26
27 /**
28 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
29 */
30 public function testCompare()
31 {
32 $collator = $this->getCollator('en');
33 $collator->compare('a', 'b');
34 }
35
36 /**
37 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
38 */
39 public function testGetAttribute()
40 {
41 $collator = $this->getCollator('en');
42 $collator->getAttribute(Collator::NUMERIC_COLLATION);
43 }
44
45 public function testGetErrorCode()
46 {
47 $collator = $this->getCollator('en');
48 $this->assertEquals(IntlGlobals::U_ZERO_ERROR, $collator->getErrorCode());
49 }
50
51 public function testGetErrorMessage()
52 {
53 $collator = $this->getCollator('en');
54 $this->assertEquals('U_ZERO_ERROR', $collator->getErrorMessage());
55 }
56
57 public function testGetLocale()
58 {
59 $collator = $this->getCollator('en');
60 $this->assertEquals('en', $collator->getLocale());
61 }
62
63 /**
64 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
65 */
66 public function testGetSortKey()
67 {
68 $collator = $this->getCollator('en');
69 $collator->getSortKey('Hello');
70 }
71
72 /**
73 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
74 */
75 public function testGetStrength()
76 {
77 $collator = $this->getCollator('en');
78 $collator->getStrength();
79 }
80
81 /**
82 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
83 */
84 public function testSetAttribute()
85 {
86 $collator = $this->getCollator('en');
87 $collator->setAttribute(Collator::NUMERIC_COLLATION, Collator::ON);
88 }
89
90 /**
91 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
92 */
93 public function testSetStrength()
94 {
95 $collator = $this->getCollator('en');
96 $collator->setStrength(Collator::PRIMARY);
97 }
98
99 public function testStaticCreate()
100 {
101 $collator = Collator::create('en');
102 $this->assertInstanceOf('\Symfony\Component\Intl\Collator\Collator', $collator);
103 }
104
105 protected function getCollator($locale)
106 {
107 return new Collator($locale);
108 }
109}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/Verification/CollatorTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/Verification/CollatorTest.php
new file mode 100644
index 00000000..c8dbc131
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/Verification/CollatorTest.php
@@ -0,0 +1,37 @@
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\Tests\Collator\Verification;
13
14use Symfony\Component\Intl\Locale;
15use Symfony\Component\Intl\Tests\Collator\AbstractCollatorTest;
16use Symfony\Component\Intl\Util\IntlTestHelper;
17
18/**
19 * Verifies that {@link AbstractCollatorTest} matches the behavior of the
20 * {@link \Collator} class in a specific version of ICU.
21 *
22 * @author Bernhard Schussek <bschussek@gmail.com>
23 */
24class CollatorTest extends AbstractCollatorTest
25{
26 protected function setUp()
27 {
28 IntlTestHelper::requireFullIntl($this);
29
30 parent::setUp();
31 }
32
33 protected function getCollator($locale)
34 {
35 return new \Collator($locale);
36 }
37}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php
new file mode 100644
index 00000000..3ffb4909
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php
@@ -0,0 +1,932 @@
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\Tests\DateFormatter;
13
14use Symfony\Component\Intl\DateFormatter\IntlDateFormatter;
15use Symfony\Component\Intl\Globals\IntlGlobals;
16use Symfony\Component\Intl\Intl;
17
18/**
19 * Test case for IntlDateFormatter implementations.
20 *
21 * @author Bernhard Schussek <bschussek@gmail.com>
22 */
23abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase
24{
25 /**
26 * When a time zone is not specified, it uses the system default however it returns null in the getter method
27 * @covers Symfony\Component\Intl\DateFormatter\IntlDateFormatter::getTimeZoneId
28 * @see StubIntlDateFormatterTest::testDefaultTimeZoneIntl()
29 */
30 public function testConstructorDefaultTimeZone()
31 {
32 $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
33
34 // In PHP 5.5 default timezone depends on `date_default_timezone_get()` method
35 if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
36 $this->assertEquals(date_default_timezone_get(), $formatter->getTimeZoneId());
37 } else {
38 $this->assertNull($formatter->getTimeZoneId());
39 }
40 }
41
42 /**
43 * @dataProvider formatProvider
44 */
45 public function testFormat($pattern, $timestamp, $expected)
46 {
47 $errorCode = IntlGlobals::U_ZERO_ERROR;
48 $errorMessage = 'U_ZERO_ERROR';
49
50 $formatter = $this->getDefaultDateFormatter($pattern);
51 $this->assertSame($expected, $formatter->format($timestamp));
52 $this->assertIsIntlSuccess($formatter, $errorMessage, $errorCode);
53 }
54
55 public function formatProvider()
56 {
57 $formatData = array(
58 /* general */
59 array('y-M-d', 0, '1970-1-1'),
60 array("EEE, MMM d, ''yy", 0, "Thu, Jan 1, '70"),
61 array('h:mm a', 0, '12:00 AM'),
62 array('yyyyy.MMMM.dd hh:mm aaa', 0, '01970.January.01 12:00 AM'),
63
64 /* escaping */
65 array("'M'", 0, 'M'),
66 array("'yy'", 0, 'yy'),
67 array("'''yy'", 0, "'yy"),
68 array("''y", 0, "'1970"),
69 array("''yy", 0, "'70"),
70 array("H 'o'' clock'", 0, "0 o' clock"),
71
72 /* month */
73 array('M', 0, '1'),
74 array('MM', 0, '01'),
75 array('MMM', 0, 'Jan'),
76 array('MMMM', 0, 'January'),
77 array('MMMMM', 0, 'J'),
78 array('MMMMMM', 0, '000001'),
79
80 array('L', 0, '1'),
81 array('LL', 0, '01'),
82 array('LLL', 0, 'Jan'),
83 array('LLLL', 0, 'January'),
84 array('LLLLL', 0, 'J'),
85 array('LLLLLL', 0, '000001'),
86
87 /* year */
88 array('y', 0, '1970'),
89 array('yy', 0, '70'),
90 array('yyy', 0, '1970'),
91 array('yyyy', 0, '1970'),
92 array('yyyyy', 0, '01970'),
93 array('yyyyyy', 0, '001970'),
94
95 /* day */
96 array('d', 0, '1'),
97 array('dd', 0, '01'),
98 array('ddd', 0, '001'),
99
100 /* quarter */
101 array('Q', 0, '1'),
102 array('QQ', 0, '01'),
103 array('QQQ', 0, 'Q1'),
104 array('QQQQ', 0, '1st quarter'),
105 array('QQQQQ', 0, '1st quarter'),
106
107 array('q', 0, '1'),
108 array('qq', 0, '01'),
109 array('qqq', 0, 'Q1'),
110 array('qqqq', 0, '1st quarter'),
111 array('qqqqq', 0, '1st quarter'),
112
113 // 4 months
114 array('Q', 7776000, '2'),
115 array('QQ', 7776000, '02'),
116 array('QQQ', 7776000, 'Q2'),
117 array('QQQQ', 7776000, '2nd quarter'),
118
119 // 7 months
120 array('QQQQ', 15638400, '3rd quarter'),
121
122 // 10 months
123 array('QQQQ', 23587200, '4th quarter'),
124
125 /* 12-hour (1-12) */
126 array('h', 0, '12'),
127 array('hh', 0, '12'),
128 array('hhh', 0, '012'),
129
130 array('h', 1, '12'),
131 array('h', 3600, '1'),
132 array('h', 43200, '12'), // 12 hours
133
134 /* day of year */
135 array('D', 0, '1'),
136 array('D', 86400, '2'), // 1 day
137 array('D', 31536000, '1'), // 1 year
138 array('D', 31622400, '2'), // 1 year + 1 day
139
140 /* day of week */
141 array('E', 0, 'Thu'),
142 array('EE', 0, 'Thu'),
143 array('EEE', 0, 'Thu'),
144 array('EEEE', 0, 'Thursday'),
145 array('EEEEE', 0, 'T'),
146 array('EEEEEE', 0, 'Thu'),
147
148 array('E', 1296540000, 'Tue'), // 2011-02-01
149 array('E', 1296950400, 'Sun'), // 2011-02-06
150
151 /* am/pm marker */
152 array('a', 0, 'AM'),
153 array('aa', 0, 'AM'),
154 array('aaa', 0, 'AM'),
155 array('aaaa', 0, 'AM'),
156
157 // 12 hours
158 array('a', 43200, 'PM'),
159 array('aa', 43200, 'PM'),
160 array('aaa', 43200, 'PM'),
161 array('aaaa', 43200, 'PM'),
162
163 /* 24-hour (0-23) */
164 array('H', 0, '0'),
165 array('HH', 0, '00'),
166 array('HHH', 0, '000'),
167
168 array('H', 1, '0'),
169 array('H', 3600, '1'),
170 array('H', 43200, '12'),
171 array('H', 46800, '13'),
172
173 /* 24-hour (1-24) */
174 array('k', 0, '24'),
175 array('kk', 0, '24'),
176 array('kkk', 0, '024'),
177
178 array('k', 1, '24'),
179 array('k', 3600, '1'),
180 array('k', 43200, '12'),
181 array('k', 46800, '13'),
182
183 /* 12-hour (0-11) */
184 array('K', 0, '0'),
185 array('KK', 0, '00'),
186 array('KKK', 0, '000'),
187
188 array('K', 1, '0'),
189 array('K', 3600, '1'),
190 array('K', 43200, '0'), // 12 hours
191
192 /* minute */
193 array('m', 0, '0'),
194 array('mm', 0, '00'),
195 array('mmm', 0, '000'),
196
197 array('m', 1, '0'),
198 array('m', 60, '1'),
199 array('m', 120, '2'),
200 array('m', 180, '3'),
201 array('m', 3600, '0'),
202 array('m', 3660, '1'),
203 array('m', 43200, '0'), // 12 hours
204
205 /* second */
206 array('s', 0, '0'),
207 array('ss', 0, '00'),
208 array('sss', 0, '000'),
209
210 array('s', 1, '1'),
211 array('s', 2, '2'),
212 array('s', 5, '5'),
213 array('s', 30, '30'),
214 array('s', 59, '59'),
215 array('s', 60, '0'),
216 array('s', 120, '0'),
217 array('s', 180, '0'),
218 array('s', 3600, '0'),
219 array('s', 3601, '1'),
220 array('s', 3630, '30'),
221 array('s', 43200, '0'), // 12 hours
222
223 // general
224 array("yyyy.MM.dd 'at' HH:mm:ss zzz", 0, '1970.01.01 at 00:00:00 GMT'),
225 array('K:mm a, z', 0, '0:00 AM, GMT'),
226
227 // timezone
228 array('z', 0, 'GMT'),
229 array('zz', 0, 'GMT'),
230 array('zzz', 0, 'GMT'),
231 array('zzzz', 0, 'GMT'),
232 array('zzzzz', 0, 'GMT'),
233 );
234
235 // As of PHP 5.3.4, IntlDateFormatter::format() accepts DateTime instances
236 if (version_compare(PHP_VERSION, '5.3.4', '>=')) {
237 $dateTime = new \DateTime('@0');
238
239 /* general, DateTime */
240 $formatData[] = array('y-M-d', $dateTime, '1970-1-1');
241 $formatData[] = array("EEE, MMM d, ''yy", $dateTime, "Thu, Jan 1, '70");
242 $formatData[] = array('h:mm a', $dateTime, '12:00 AM');
243 $formatData[] = array('yyyyy.MMMM.dd hh:mm aaa', $dateTime, '01970.January.01 12:00 AM');
244
245 $formatData[] = array("yyyy.MM.dd 'at' HH:mm:ss zzz", $dateTime, '1970.01.01 at 00:00:00 GMT');
246 $formatData[] = array('K:mm a, z', $dateTime, '0:00 AM, GMT');
247 }
248
249 return $formatData;
250 }
251
252 /**
253 * @dataProvider formatErrorProvider
254 */
255 public function testFormatIllegalArgumentError($pattern, $timestamp, $errorMessage)
256 {
257 $errorCode = IntlGlobals::U_ILLEGAL_ARGUMENT_ERROR;
258
259 $formatter = $this->getDefaultDateFormatter($pattern);
260 $this->assertFalse($formatter->format($timestamp));
261 $this->assertIsIntlFailure($formatter, $errorMessage, $errorCode);
262 }
263
264 public function formatErrorProvider()
265 {
266 // With PHP 5.5 IntlDateFormatter accepts empty values ('0')
267 if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
268 return array(
269 array('y-M-d', 'foobar', 'datefmt_format: string \'foobar\' is not numeric, which would be required for it to be a valid date: U_ILLEGAL_ARGUMENT_ERROR')
270 );
271 }
272
273 $message = 'datefmt_format: takes either an array or an integer timestamp value : U_ILLEGAL_ARGUMENT_ERROR';
274
275 if (version_compare(PHP_VERSION, '5.3.4', '>=')) {
276 $message = 'datefmt_format: takes either an array or an integer timestamp value or a DateTime object: U_ILLEGAL_ARGUMENT_ERROR';
277 }
278
279 return array(
280 array('y-M-d', '0', $message),
281 array('y-M-d', 'foobar', $message),
282 );
283 }
284
285 /**
286 * @dataProvider formatWithTimezoneProvider
287 */
288 public function testFormatWithTimezone($timestamp, $timezone, $expected)
289 {
290 $pattern = 'yyyy-MM-dd HH:mm:ss';
291 $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, $timezone, IntlDateFormatter::GREGORIAN, $pattern);
292 $this->assertSame($expected, $formatter->format($timestamp));
293 }
294
295 public function formatWithTimezoneProvider()
296 {
297 $data = array(
298 array(0, 'UTC', '1970-01-01 00:00:00'),
299 array(0, 'GMT', '1970-01-01 00:00:00'),
300 array(0, 'GMT-03:00', '1969-12-31 21:00:00'),
301 array(0, 'GMT+03:00', '1970-01-01 03:00:00'),
302 array(0, 'Europe/Zurich', '1970-01-01 01:00:00'),
303 array(0, 'Europe/Paris', '1970-01-01 01:00:00'),
304 array(0, 'Africa/Cairo', '1970-01-01 02:00:00'),
305 array(0, 'Africa/Casablanca', '1970-01-01 00:00:00'),
306 array(0, 'Africa/Djibouti', '1970-01-01 03:00:00'),
307 array(0, 'Africa/Johannesburg', '1970-01-01 02:00:00'),
308 array(0, 'America/Antigua', '1969-12-31 20:00:00'),
309 array(0, 'America/Toronto', '1969-12-31 19:00:00'),
310 array(0, 'America/Vancouver', '1969-12-31 16:00:00'),
311 array(0, 'Asia/Aqtau', '1970-01-01 05:00:00'),
312 array(0, 'Asia/Bangkok', '1970-01-01 07:00:00'),
313 array(0, 'Asia/Dubai', '1970-01-01 04:00:00'),
314 array(0, 'Australia/Brisbane', '1970-01-01 10:00:00'),
315 array(0, 'Australia/Eucla', '1970-01-01 08:45:00'),
316 array(0, 'Australia/Melbourne', '1970-01-01 10:00:00'),
317 array(0, 'Europe/Berlin', '1970-01-01 01:00:00'),
318 array(0, 'Europe/Dublin', '1970-01-01 01:00:00'),
319 array(0, 'Europe/Warsaw', '1970-01-01 01:00:00'),
320 array(0, 'Pacific/Fiji', '1970-01-01 12:00:00'),
321 );
322
323 // As of PHP 5.5, intl ext no longer fallbacks invalid time zones to UTC
324 if (!version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
325 // When time zone not exists, uses UTC by default
326 $data[] = array(0, 'Foo/Bar', '1970-01-01 00:00:00');
327 $data[] = array(0, 'UTC+04:30', '1970-01-01 00:00:00');
328 $data[] = array(0, 'UTC+04:AA', '1970-01-01 00:00:00');
329 }
330
331 return $data;
332 }
333
334 public function testFormatWithGmtTimezone()
335 {
336 $formatter = $this->getDefaultDateFormatter('zzzz');
337
338 if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
339 $formatter->setTimeZone('GMT+03:00');
340 } else {
341 $formatter->setTimeZoneId('GMT+03:00');
342 }
343
344 $this->assertEquals('GMT+03:00', $formatter->format(0));
345 }
346
347 public function testFormatWithGmtTimeZoneAndMinutesOffset()
348 {
349 $formatter = $this->getDefaultDateFormatter('zzzz');
350
351 if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
352 $formatter->setTimeZone('GMT+00:30');
353 } else {
354 $formatter->setTimeZoneId('GMT+00:30');
355 }
356
357 $this->assertEquals('GMT+00:30', $formatter->format(0));
358 }
359
360 public function testFormatWithNonStandardTimezone()
361 {
362 $formatter = $this->getDefaultDateFormatter('zzzz');
363
364 if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
365 $formatter->setTimeZone('Pacific/Fiji');
366 } else {
367 $formatter->setTimeZoneId('Pacific/Fiji');
368 }
369
370 $this->assertEquals('Fiji Standard Time', $formatter->format(0));
371 }
372
373 public function testFormatWithConstructorTimezone()
374 {
375 $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'UTC');
376 $formatter->setPattern('yyyy-MM-dd HH:mm:ss');
377
378 $this->assertEquals(
379 $this->getDateTime(0)->format('Y-m-d H:i:s'),
380 $formatter->format(0)
381 );
382 }
383
384 public function testFormatWithTimezoneFromEnvironmentVariable()
385 {
386 if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
387 $this->markTestSkipped('IntlDateFormatter in PHP 5.5 no longer depends on TZ environment.');
388 }
389
390 $tz = getenv('TZ');
391 putenv('TZ=Europe/London');
392
393 $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
394 $formatter->setPattern('yyyy-MM-dd HH:mm:ss');
395
396 $this->assertEquals(
397 $this->getDateTime(0)->format('Y-m-d H:i:s'),
398 $formatter->format(0)
399 );
400
401 $this->assertEquals('Europe/London', getenv('TZ'));
402
403 // Restores TZ.
404 putenv('TZ='.$tz);
405 }
406
407 public function testFormatWithTimezoneFromPhp()
408 {
409 if (!version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
410 $this->markTestSkipped('Only in PHP 5.5 IntlDateFormatter depends on default timezone (`date_default_timezone_get()`).');
411 }
412
413 $tz = date_default_timezone_get();
414 date_default_timezone_set('Europe/London');
415
416 $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
417 $formatter->setPattern('yyyy-MM-dd HH:mm:ss');
418
419 $this->assertEquals(
420 $this->getDateTime(0)->format('Y-m-d H:i:s'),
421 $formatter->format(0)
422 );
423
424 $this->assertEquals('Europe/London', date_default_timezone_get());
425
426 // Restores TZ.
427 date_default_timezone_set($tz);
428 }
429
430 /**
431 * @dataProvider dateAndTimeTypeProvider
432 */
433 public function testDateAndTimeType($timestamp, $datetype, $timetype, $expected)
434 {
435 $formatter = $this->getDateFormatter('en', $datetype, $timetype, 'UTC');
436 $this->assertSame($expected, $formatter->format($timestamp));
437 }
438
439 public function dateAndTimeTypeProvider()
440 {
441 return array(
442 array(0, IntlDateFormatter::FULL, IntlDateFormatter::NONE, 'Thursday, January 1, 1970'),
443 array(0, IntlDateFormatter::LONG, IntlDateFormatter::NONE, 'January 1, 1970'),
444 array(0, IntlDateFormatter::MEDIUM, IntlDateFormatter::NONE, 'Jan 1, 1970'),
445 array(0, IntlDateFormatter::SHORT, IntlDateFormatter::NONE, '1/1/70'),
446 array(0, IntlDateFormatter::NONE, IntlDateFormatter::FULL, '12:00:00 AM GMT'),
447 array(0, IntlDateFormatter::NONE, IntlDateFormatter::LONG, '12:00:00 AM GMT'),
448 array(0, IntlDateFormatter::NONE, IntlDateFormatter::MEDIUM, '12:00:00 AM'),
449 array(0, IntlDateFormatter::NONE, IntlDateFormatter::SHORT, '12:00 AM'),
450 );
451 }
452
453 public function testGetCalendar()
454 {
455 $formatter = $this->getDefaultDateFormatter();
456 $this->assertEquals(IntlDateFormatter::GREGORIAN, $formatter->getCalendar());
457 }
458
459 public function testGetDateType()
460 {
461 $formatter = $this->getDateFormatter('en', IntlDateFormatter::FULL, IntlDateFormatter::NONE);
462 $this->assertEquals(IntlDateFormatter::FULL, $formatter->getDateType());
463 }
464
465 public function testGetLocale()
466 {
467 $formatter = $this->getDefaultDateFormatter();
468 $this->assertEquals('en', $formatter->getLocale());
469 }
470
471 public function testGetPattern()
472 {
473 $formatter = $this->getDateFormatter('en', IntlDateFormatter::FULL, IntlDateFormatter::NONE, 'UTC', IntlDateFormatter::GREGORIAN, 'yyyy-MM-dd');
474 $this->assertEquals('yyyy-MM-dd', $formatter->getPattern());
475 }
476
477 public function testGetTimeType()
478 {
479 $formatter = $this->getDateFormatter('en', IntlDateFormatter::NONE, IntlDateFormatter::FULL);
480 $this->assertEquals(IntlDateFormatter::FULL, $formatter->getTimeType());
481 }
482
483 /**
484 * @dataProvider parseProvider
485 */
486 public function testParse($pattern, $value, $expected)
487 {
488 $errorCode = IntlGlobals::U_ZERO_ERROR;
489 $errorMessage = 'U_ZERO_ERROR';
490
491 $formatter = $this->getDefaultDateFormatter($pattern);
492 $this->assertSame($expected, $formatter->parse($value));
493 $this->assertIsIntlSuccess($formatter, $errorMessage, $errorCode);
494 }
495
496 public function parseProvider()
497 {
498 return array_merge(
499 $this->parseYearProvider(),
500 $this->parseQuarterProvider(),
501 $this->parseMonthProvider(),
502 $this->parseStandaloneMonthProvider(),
503 $this->parseDayProvider(),
504 $this->parseDayOfWeekProvider(),
505 $this->parseDayOfYearProvider(),
506 $this->parseHour12ClockOneBasedProvider(),
507 $this->parseHour12ClockZeroBasedProvider(),
508 $this->parseHour24ClockOneBasedProvider(),
509 $this->parseHour24ClockZeroBasedProvider(),
510 $this->parseMinuteProvider(),
511 $this->parseSecondProvider(),
512 $this->parseTimezoneProvider(),
513 $this->parseAmPmProvider(),
514 $this->parseStandaloneAmPmProvider(),
515 $this->parseRegexMetaCharsProvider(),
516 $this->parseQuoteCharsProvider(),
517 $this->parseDashSlashProvider()
518 );
519 }
520
521 public function parseYearProvider()
522 {
523 return array(
524 array('y-M-d', '1970-1-1', 0),
525 array('yy-M-d', '70-1-1', 0),
526 );
527 }
528
529 public function parseQuarterProvider()
530 {
531 return array(
532 array('Q', '1', 0),
533 array('QQ', '01', 0),
534 array('QQQ', 'Q1', 0),
535 array('QQQQ', '1st quarter', 0),
536 array('QQQQQ', '1st quarter', 0),
537
538 array('Q', '2', 7776000),
539 array('QQ', '02', 7776000),
540 array('QQQ', 'Q2', 7776000),
541 array('QQQQ', '2nd quarter', 7776000),
542 array('QQQQQ', '2nd quarter', 7776000),
543
544 array('q', '1', 0),
545 array('qq', '01', 0),
546 array('qqq', 'Q1', 0),
547 array('qqqq', '1st quarter', 0),
548 array('qqqqq', '1st quarter', 0),
549 );
550 }
551
552 public function parseMonthProvider()
553 {
554 return array(
555 array('y-M-d', '1970-1-1', 0),
556 array('y-MMM-d', '1970-Jan-1', 0),
557 array('y-MMMM-d', '1970-January-1', 0),
558 );
559 }
560
561 public function parseStandaloneMonthProvider()
562 {
563 return array(
564 array('y-L-d', '1970-1-1', 0),
565 array('y-LLL-d', '1970-Jan-1', 0),
566 array('y-LLLL-d', '1970-January-1', 0),
567 );
568 }
569
570 public function parseDayProvider()
571 {
572 return array(
573 array('y-M-d', '1970-1-1', 0),
574 array('y-M-dd', '1970-1-01', 0),
575 array('y-M-ddd', '1970-1-001', 0),
576 );
577 }
578
579 public function parseDayOfWeekProvider()
580 {
581 return array(
582 array('E', 'Thu', 0),
583 array('EE', 'Thu', 0),
584 array('EEE', 'Thu', 0),
585 array('EEEE', 'Thursday', 0),
586 array('EEEEE', 'T', 432000),
587 array('EEEEEE', 'Thu', 0),
588 );
589 }
590
591 public function parseDayOfYearProvider()
592 {
593 return array(
594 array('D', '1', 0),
595 array('D', '2', 86400),
596 );
597 }
598
599 public function parseHour12ClockOneBasedProvider()
600 {
601 return array(
602 // 12 hours (1-12)
603 array('y-M-d h', '1970-1-1 1', 3600),
604 array('y-M-d h', '1970-1-1 10', 36000),
605 array('y-M-d hh', '1970-1-1 11', 39600),
606 array('y-M-d hh', '1970-1-1 12', 0),
607 array('y-M-d hh a', '1970-1-1 0 AM', 0),
608 array('y-M-d hh a', '1970-1-1 1 AM', 3600),
609 array('y-M-d hh a', '1970-1-1 10 AM', 36000),
610 array('y-M-d hh a', '1970-1-1 11 AM', 39600),
611 array('y-M-d hh a', '1970-1-1 12 AM', 0),
612 array('y-M-d hh a', '1970-1-1 23 AM', 82800),
613 array('y-M-d hh a', '1970-1-1 24 AM', 86400),
614 array('y-M-d hh a', '1970-1-1 0 PM', 43200),
615 array('y-M-d hh a', '1970-1-1 1 PM', 46800),
616 array('y-M-d hh a', '1970-1-1 10 PM', 79200),
617 array('y-M-d hh a', '1970-1-1 11 PM', 82800),
618 array('y-M-d hh a', '1970-1-1 12 PM', 43200),
619 array('y-M-d hh a', '1970-1-1 23 PM', 126000),
620 array('y-M-d hh a', '1970-1-1 24 PM', 129600),
621 );
622 }
623
624 public function parseHour12ClockZeroBasedProvider()
625 {
626 return array(
627 // 12 hours (0-11)
628 array('y-M-d K', '1970-1-1 1', 3600),
629 array('y-M-d K', '1970-1-1 10', 36000),
630 array('y-M-d KK', '1970-1-1 11', 39600),
631 array('y-M-d KK', '1970-1-1 12', 43200),
632 array('y-M-d KK a', '1970-1-1 0 AM', 0),
633 array('y-M-d KK a', '1970-1-1 1 AM', 3600),
634 array('y-M-d KK a', '1970-1-1 10 AM', 36000),
635 array('y-M-d KK a', '1970-1-1 11 AM', 39600),
636 array('y-M-d KK a', '1970-1-1 12 AM', 43200),
637 array('y-M-d KK a', '1970-1-1 23 AM', 82800),
638 array('y-M-d KK a', '1970-1-1 24 AM', 86400),
639 array('y-M-d KK a', '1970-1-1 0 PM', 43200),
640 array('y-M-d KK a', '1970-1-1 1 PM', 46800),
641 array('y-M-d KK a', '1970-1-1 10 PM', 79200),
642 array('y-M-d KK a', '1970-1-1 11 PM', 82800),
643 array('y-M-d KK a', '1970-1-1 12 PM', 86400),
644 array('y-M-d KK a', '1970-1-1 23 PM', 126000),
645 array('y-M-d KK a', '1970-1-1 24 PM', 129600),
646 );
647 }
648
649 public function parseHour24ClockOneBasedProvider()
650 {
651 return array(
652 // 24 hours (1-24)
653 array('y-M-d k', '1970-1-1 1', 3600),
654 array('y-M-d k', '1970-1-1 10', 36000),
655 array('y-M-d kk', '1970-1-1 11', 39600),
656 array('y-M-d kk', '1970-1-1 12', 43200),
657 array('y-M-d kk', '1970-1-1 23', 82800),
658 array('y-M-d kk', '1970-1-1 24', 0),
659 array('y-M-d kk a', '1970-1-1 0 AM', 0),
660 array('y-M-d kk a', '1970-1-1 1 AM', 0),
661 array('y-M-d kk a', '1970-1-1 10 AM', 0),
662 array('y-M-d kk a', '1970-1-1 11 AM', 0),
663 array('y-M-d kk a', '1970-1-1 12 AM', 0),
664 array('y-M-d kk a', '1970-1-1 23 AM', 0),
665 array('y-M-d kk a', '1970-1-1 24 AM', 0),
666 array('y-M-d kk a', '1970-1-1 0 PM', 43200),
667 array('y-M-d kk a', '1970-1-1 1 PM', 43200),
668 array('y-M-d kk a', '1970-1-1 10 PM', 43200),
669 array('y-M-d kk a', '1970-1-1 11 PM', 43200),
670 array('y-M-d kk a', '1970-1-1 12 PM', 43200),
671 array('y-M-d kk a', '1970-1-1 23 PM', 43200),
672 array('y-M-d kk a', '1970-1-1 24 PM', 43200),
673 );
674 }
675
676 public function parseHour24ClockZeroBasedProvider()
677 {
678 return array(
679 // 24 hours (0-23)
680 array('y-M-d H', '1970-1-1 0', 0),
681 array('y-M-d H', '1970-1-1 1', 3600),
682 array('y-M-d H', '1970-1-1 10', 36000),
683 array('y-M-d HH', '1970-1-1 11', 39600),
684 array('y-M-d HH', '1970-1-1 12', 43200),
685 array('y-M-d HH', '1970-1-1 23', 82800),
686 array('y-M-d HH a', '1970-1-1 0 AM', 0),
687 array('y-M-d HH a', '1970-1-1 1 AM', 0),
688 array('y-M-d HH a', '1970-1-1 10 AM', 0),
689 array('y-M-d HH a', '1970-1-1 11 AM', 0),
690 array('y-M-d HH a', '1970-1-1 12 AM', 0),
691 array('y-M-d HH a', '1970-1-1 23 AM', 0),
692 array('y-M-d HH a', '1970-1-1 24 AM', 0),
693 array('y-M-d HH a', '1970-1-1 0 PM', 43200),
694 array('y-M-d HH a', '1970-1-1 1 PM', 43200),
695 array('y-M-d HH a', '1970-1-1 10 PM', 43200),
696 array('y-M-d HH a', '1970-1-1 11 PM', 43200),
697 array('y-M-d HH a', '1970-1-1 12 PM', 43200),
698 array('y-M-d HH a', '1970-1-1 23 PM', 43200),
699 array('y-M-d HH a', '1970-1-1 24 PM', 43200),
700 );
701 }
702
703 public function parseMinuteProvider()
704 {
705 return array(
706 array('y-M-d HH:m', '1970-1-1 0:1', 60),
707 array('y-M-d HH:mm', '1970-1-1 0:10', 600),
708 );
709 }
710
711 public function parseSecondProvider()
712 {
713 return array(
714 array('y-M-d HH:mm:s', '1970-1-1 00:01:1', 61),
715 array('y-M-d HH:mm:ss', '1970-1-1 00:01:10', 70),
716 );
717 }
718
719 public function parseTimezoneProvider()
720 {
721 return array(
722 array('y-M-d HH:mm:ss zzzz', '1970-1-1 00:00:00 GMT-03:00', 10800),
723 array('y-M-d HH:mm:ss zzzz', '1970-1-1 00:00:00 GMT-04:00', 14400),
724 array('y-M-d HH:mm:ss zzzz', '1970-1-1 00:00:00 GMT-00:00', 0),
725 array('y-M-d HH:mm:ss zzzz', '1970-1-1 00:00:00 GMT+03:00', -10800),
726 array('y-M-d HH:mm:ss zzzz', '1970-1-1 00:00:00 GMT+04:00', -14400),
727 array('y-M-d HH:mm:ss zzzz', '1970-1-1 00:00:00 GMT-0300', 10800),
728 array('y-M-d HH:mm:ss zzzz', '1970-1-1 00:00:00 GMT+0300', -10800),
729
730 // a previous timezone parsing should not change the timezone for the next parsing
731 array('y-M-d HH:mm:ss', '1970-1-1 00:00:00', 0),
732 );
733 }
734
735 public function parseAmPmProvider()
736 {
737 return array(
738 // AM/PM (already covered by hours tests)
739 array('y-M-d HH:mm:ss a', '1970-1-1 00:00:00 AM', 0),
740 array('y-M-d HH:mm:ss a', '1970-1-1 00:00:00 PM', 43200),
741 );
742 }
743
744 public function parseStandaloneAmPmProvider()
745 {
746 return array(
747 array('a', 'AM', 0),
748 array('a', 'PM', 43200),
749 );
750 }
751
752 public function parseRegexMetaCharsProvider()
753 {
754 return array(
755 // regexp meta chars in the pattern string
756 array('y[M-d', '1970[1-1', 0),
757 array('y[M/d', '1970[1/1', 0),
758 );
759 }
760
761 public function parseQuoteCharsProvider()
762 {
763 return array(
764 array("'M'", 'M', 0),
765 array("'yy'", 'yy', 0),
766 array("'''yy'", "'yy", 0),
767 array("''y", "'1970", 0),
768 array("H 'o'' clock'", "0 o' clock", 0),
769 );
770 }
771
772 public function parseDashSlashProvider()
773 {
774 return array(
775 array('y-M-d', '1970/1/1', 0),
776 array('yy-M-d', '70/1/1', 0),
777 array('y/M/d', '1970-1-1', 0),
778 array('yy/M/d', '70-1-1', 0),
779 );
780 }
781
782 /**
783 * @dataProvider parseErrorProvider
784 */
785 public function testParseError($pattern, $value)
786 {
787 $errorCode = IntlGlobals::U_PARSE_ERROR;
788 $errorMessage = 'Date parsing failed: U_PARSE_ERROR';
789
790 $formatter = $this->getDefaultDateFormatter($pattern);
791 $this->assertFalse($formatter->parse($value));
792 $this->assertIsIntlFailure($formatter, $errorMessage, $errorCode);
793 }
794
795 public function parseErrorProvider()
796 {
797 return array(
798 // 1 char month
799 array('y-MMMMM-d', '1970-J-1'),
800 array('y-MMMMM-d', '1970-S-1'),
801
802 // standalone 1 char month
803 array('y-LLLLL-d', '1970-J-1'),
804 array('y-LLLLL-d', '1970-S-1'),
805 );
806 }
807
808 /*
809 * https://github.com/symfony/symfony/issues/4242
810 */
811 public function testParseAfterError()
812 {
813 $this->testParseError('y-MMMMM-d', '1970-J-1');
814 $this->testParse('y-M-d', '1970-1-1', 0);
815 }
816
817 public function testParseWithNullPositionValue()
818 {
819 $position = null;
820 $formatter = $this->getDefaultDateFormatter('y');
821 $this->assertSame(0, $formatter->parse('1970', $position));
822 $this->assertNull($position);
823 }
824
825 public function testSetPattern()
826 {
827 $formatter = $this->getDefaultDateFormatter();
828 $formatter->setPattern('yyyy-MM-dd');
829 $this->assertEquals('yyyy-MM-dd', $formatter->getPattern());
830 }
831
832 /**
833 * @covers Symfony\Component\Intl\DateFormatter\IntlDateFormatter::getTimeZoneId
834 * @dataProvider setTimeZoneIdProvider
835 */
836 public function testSetTimeZoneId($timeZoneId, $expectedTimeZoneId)
837 {
838 $formatter = $this->getDefaultDateFormatter();
839
840 if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
841 $formatter->setTimeZone($timeZoneId);
842 } else {
843 $formatter->setTimeZoneId($timeZoneId);
844 }
845
846 $this->assertEquals($expectedTimeZoneId, $formatter->getTimeZoneId());
847 }
848
849 public function setTimeZoneIdProvider()
850 {
851 return array(
852 array('UTC', 'UTC'),
853 array('GMT', 'GMT'),
854 array('GMT-03:00', 'GMT-03:00'),
855 array('Europe/Zurich', 'Europe/Zurich'),
856 array('GMT-0300', 'GMT-0300'),
857 array('Foo/Bar', 'Foo/Bar'),
858 array('GMT+00:AA', 'GMT+00:AA'),
859 array('GMT+00AA', 'GMT+00AA'),
860 );
861 }
862
863 protected function getDefaultDateFormatter($pattern = null)
864 {
865 return $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'UTC', IntlDateFormatter::GREGORIAN, $pattern);
866 }
867
868 protected function getDateTime($timestamp = null)
869 {
870 if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
871 $timeZone = date_default_timezone_get();
872 } else {
873 $timeZone = getenv('TZ') ?: 'UTC';
874 }
875
876 $dateTime = new \DateTime();
877 $dateTime->setTimestamp(null === $timestamp ? time() : $timestamp);
878 $dateTime->setTimeZone(new \DateTimeZone($timeZone));
879
880 return $dateTime;
881 }
882
883 protected function assertIsIntlFailure($formatter, $errorMessage, $errorCode)
884 {
885 $this->assertSame($errorMessage, $this->getIntlErrorMessage());
886 $this->assertSame($errorCode, $this->getIntlErrorCode());
887 $this->assertTrue($this->isIntlFailure($this->getIntlErrorCode()));
888 $this->assertSame($errorMessage, $formatter->getErrorMessage());
889 $this->assertSame($errorCode, $formatter->getErrorCode());
890 $this->assertTrue($this->isIntlFailure($formatter->getErrorCode()));
891 }
892
893 protected function assertIsIntlSuccess($formatter, $errorMessage, $errorCode)
894 {
895 /* @var IntlDateFormatter $formatter */
896 $this->assertSame($errorMessage, $this->getIntlErrorMessage());
897 $this->assertSame($errorCode, $this->getIntlErrorCode());
898 $this->assertFalse($this->isIntlFailure($this->getIntlErrorCode()));
899 $this->assertSame($errorMessage, $formatter->getErrorMessage());
900 $this->assertSame($errorCode, $formatter->getErrorCode());
901 $this->assertFalse($this->isIntlFailure($formatter->getErrorCode()));
902 }
903
904 /**
905 * @param $locale
906 * @param $datetype
907 * @param $timetype
908 * @param null $timezone
909 * @param int $calendar
910 * @param null $pattern
911 *
912 * @return mixed
913 */
914 abstract protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null);
915
916 /**
917 * @return string
918 */
919 abstract protected function getIntlErrorMessage();
920
921 /**
922 * @return integer
923 */
924 abstract protected function getIntlErrorCode();
925
926 /**
927 * @param integer $errorCode
928 *
929 * @return Boolean
930 */
931 abstract protected function isIntlFailure($errorCode);
932}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php
new file mode 100644
index 00000000..d7227aeb
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php
@@ -0,0 +1,220 @@
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\Tests\DateFormatter;
13
14use Symfony\Component\Intl\DateFormatter\IntlDateFormatter;
15use Symfony\Component\Intl\Globals\IntlGlobals;
16
17class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
18{
19 public function testConstructor()
20 {
21 $formatter = new IntlDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'UTC', IntlDateFormatter::GREGORIAN, 'y-M-d');
22 $this->assertEquals('y-M-d', $formatter->getPattern());
23 }
24
25 /**
26 * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
27 */
28 public function testConstructorWithUnsupportedLocale()
29 {
30 new IntlDateFormatter('pt_BR', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
31 }
32
33 public function testStaticCreate()
34 {
35 $formatter = IntlDateFormatter::create('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
36 $this->assertInstanceOf('\Symfony\Component\Intl\DateFormatter\IntlDateFormatter', $formatter);
37 }
38
39 public function testFormatWithUnsupportedTimestampArgument()
40 {
41 $formatter = $this->getDefaultDateFormatter();
42
43 $localtime = array(
44 'tm_sec' => 59,
45 'tm_min' => 3,
46 'tm_hour' => 15,
47 'tm_mday' => 15,
48 'tm_mon' => 3,
49 'tm_year' => 112,
50 'tm_wday' => 0,
51 'tm_yday' => 105,
52 'tm_isdst' => 0
53 );
54
55 try {
56 $formatter->format($localtime);
57 } catch (\Exception $e) {
58 $this->assertInstanceOf('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException', $e);
59
60 if (version_compare(PHP_VERSION, '5.3.4', '>=')) {
61 $this->assertStringEndsWith('Only integer unix timestamps and DateTime objects are supported. Please install the "intl" extension for full localization capabilities.', $e->getMessage());
62 } else {
63 $this->assertStringEndsWith('Only integer unix timestamps are supported. Please install the "intl" extension for full localization capabilities.', $e->getMessage());
64 }
65 }
66 }
67
68 /**
69 * @expectedException \Symfony\Component\Intl\Exception\NotImplementedException
70 */
71 public function testFormatWithUnimplementedChars()
72 {
73 $pattern = 'Y';
74 $formatter = new IntlDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'UTC', IntlDateFormatter::GREGORIAN, $pattern);
75 $formatter->format(0);
76 }
77
78 /**
79 * @expectedException \Symfony\Component\Intl\Exception\NotImplementedException
80 */
81 public function testFormatWithNonIntegerTimestamp()
82 {
83 $formatter = $this->getDefaultDateFormatter();
84 $formatter->format(array());
85 }
86
87 public function testGetErrorCode()
88 {
89 $formatter = $this->getDefaultDateFormatter();
90 $this->assertEquals(IntlGlobals::getErrorCode(), $formatter->getErrorCode());
91 }
92
93 public function testGetErrorMessage()
94 {
95 $formatter = $this->getDefaultDateFormatter();
96 $this->assertEquals(IntlGlobals::getErrorMessage(), $formatter->getErrorMessage());
97 }
98
99 public function testIsLenient()
100 {
101 $formatter = $this->getDefaultDateFormatter();
102 $this->assertFalse($formatter->isLenient());
103 }
104
105 /**
106 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
107 */
108 public function testLocaltime()
109 {
110 $formatter = $this->getDefaultDateFormatter();
111 $formatter->localtime('Wednesday, December 31, 1969 4:00:00 PM PT');
112 }
113
114 /**
115 * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException
116 */
117 public function testParseWithNotNullPositionValue()
118 {
119 $position = 0;
120 $formatter = $this->getDefaultDateFormatter('y');
121 $this->assertSame(0, $formatter->parse('1970', $position));
122 }
123
124 /**
125 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
126 */
127 public function testSetCalendar()
128 {
129 $formatter = $this->getDefaultDateFormatter();
130 $formatter->setCalendar(IntlDateFormatter::GREGORIAN);
131 }
132
133 /**
134 * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
135 */
136 public function testSetLenient()
137 {
138 $formatter = $this->getDefaultDateFormatter();
139 $formatter->setLenient(true);
140 }
141
142 /**
143 * @expectedException \Symfony\Component\Intl\Exception\NotImplementedException
144 */
145 public function testFormatWithGmtTimeZoneAndMinutesOffset()
146 {
147 parent::testFormatWithGmtTimeZoneAndMinutesOffset();
148 }
149
150 /**
151 * @expectedException \Symfony\Component\Intl\Exception\NotImplementedException
152 */
153 public function testFormatWithNonStandardTimezone()
154 {
155 parent::testFormatWithNonStandardTimezone();
156 }
157
158 public function parseStandaloneAmPmProvider()
159 {
160 return $this->notImplemented(parent::parseStandaloneAmPmProvider());
161 }
162
163 public function parseDayOfWeekProvider()
164 {
165 return $this->notImplemented(parent::parseDayOfWeekProvider());
166 }
167
168 public function parseDayOfYearProvider()
169 {
170 return $this->notImplemented(parent::parseDayOfYearProvider());
171 }
172
173 public function parseQuarterProvider()
174 {
175 return $this->notImplemented(parent::parseQuarterProvider());
176 }
177
178 protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null)
179 {
180 return new IntlDateFormatter($locale, $datetype, $timetype, $timezone, $calendar, $pattern);
181 }
182
183 protected function getIntlErrorMessage()
184 {
185 return IntlGlobals::getErrorMessage();
186 }
187
188 protected function getIntlErrorCode()
189 {
190 return IntlGlobals::getErrorCode();
191 }
192
193 protected function isIntlFailure($errorCode)
194 {
195 return IntlGlobals::isFailure($errorCode);
196 }
197
198 /**
199 * Just to document the differences between the stub and the intl
200 * implementations. The intl can parse any of the tested formats alone. The
201 * stub does not implement them as it would be needed to add more
202 * abstraction, passing more context to the transformers objects. Any of the
203 * formats are ignored alone or with date/time data (years, months, days,
204 * hours, minutes and seconds).
205 *
206 * Also in intl, format like 'ss E' for '10 2' (2nd day of year
207 * + 10 seconds) are added, then we have 86,400 seconds (24h * 60min * 60s)
208 * + 10 seconds
209 *
210 * @param array $dataSets
211 *
212 * @return array
213 */
214 private function notImplemented(array $dataSets)
215 {
216 return array_map(function ($row) {
217 return array($row[0], $row[1], 0);
218 }, $dataSets);
219 }
220}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/DateFormatter/Verification/IntlDateFormatterTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/DateFormatter/Verification/IntlDateFormatterTest.php
new file mode 100644
index 00000000..7fbf854f
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/DateFormatter/Verification/IntlDateFormatterTest.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\Tests\DateFormatter\Verification;
13
14use Symfony\Component\Intl\DateFormatter\IntlDateFormatter;
15use Symfony\Component\Intl\Tests\DateFormatter\AbstractIntlDateFormatterTest;
16use Symfony\Component\Intl\Util\IntlTestHelper;
17
18/**
19 * Verifies that {@link AbstractIntlDateFormatterTest} matches the behavior of
20 * the {@link \IntlDateFormatter} class in a specific version of ICU.
21 *
22 * @author Bernhard Schussek <bschussek@gmail.com>
23 */
24class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
25{
26 protected function setUp()
27 {
28 IntlTestHelper::requireFullIntl($this);
29
30 parent::setUp();
31 }
32
33 /**
34 * It seems IntlDateFormatter caches the timezone id when not explicitly set via constructor or by the
35 * setTimeZoneId() method. Since testFormatWithDefaultTimezoneIntl() runs using the default environment
36 * time zone, this test would use it too if not running in a separated process.
37 *
38 * @runInSeparateProcess
39 */
40 public function testFormatWithTimezoneFromEnvironmentVariable()
41 {
42 parent::testFormatWithTimezoneFromEnvironmentVariable();
43 }
44
45 protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null)
46 {
47 return new \IntlDateFormatter($locale, $datetype, $timetype, $timezone, $calendar, $pattern);
48 }
49
50 protected function getIntlErrorMessage()
51 {
52 return intl_get_error_message();
53 }
54
55 protected function getIntlErrorCode()
56 {
57 return intl_get_error_code();
58 }
59
60 protected function isIntlFailure($errorCode)
61 {
62 return intl_is_failure($errorCode);
63 }
64}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Globals/AbstractIntlGlobalsTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Globals/AbstractIntlGlobalsTest.php
new file mode 100644
index 00000000..0a937d5e
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Globals/AbstractIntlGlobalsTest.php
@@ -0,0 +1,41 @@
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\Tests\Globals;
13
14/**
15 * Test case for intl function implementations.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19abstract class AbstractIntlGlobalsTest extends \PHPUnit_Framework_TestCase
20{
21 public function errorNameProvider()
22 {
23 return array (
24 array(-129, '[BOGUS UErrorCode]'),
25 array(0, 'U_ZERO_ERROR'),
26 array(1, 'U_ILLEGAL_ARGUMENT_ERROR'),
27 array(9, 'U_PARSE_ERROR'),
28 array(129, '[BOGUS UErrorCode]'),
29 );
30 }
31
32 /**
33 * @dataProvider errorNameProvider
34 */
35 public function testGetErrorName($errorCode, $errorName)
36 {
37 $this->assertSame($errorName, $this->getIntlErrorName($errorCode));
38 }
39
40 abstract protected function getIntlErrorName($errorCode);
41}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Globals/IntlGlobalsTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Globals/IntlGlobalsTest.php
new file mode 100644
index 00000000..34e3a6a3
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Globals/IntlGlobalsTest.php
@@ -0,0 +1,22 @@
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\Tests\Globals;
13
14use Symfony\Component\Intl\Globals\IntlGlobals;
15
16class IntlGlobalsTest extends AbstractIntlGlobalsTest
17{
18 protected function getIntlErrorName($errorCode)
19 {
20 return IntlGlobals::getErrorName($errorCode);
21 }
22}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Globals/Verification/IntlGlobalsTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Globals/Verification/IntlGlobalsTest.php
new file mode 100644
index 00000000..c46033d8
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Globals/Verification/IntlGlobalsTest.php
@@ -0,0 +1,36 @@
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\Tests\Globals\Verification;
13
14use Symfony\Component\Intl\Tests\Globals\AbstractIntlGlobalsTest;
15use Symfony\Component\Intl\Util\IntlTestHelper;
16
17/**
18 * Verifies that {@link AbstractIntlGlobalsTest} matches the behavior of the
19 * intl functions with a specific version of ICU.
20 *
21 * @author Bernhard Schussek <bschussek@gmail.com>
22 */
23class IntlGlobalsTest extends AbstractIntlGlobalsTest
24{
25 protected function setUp()
26 {
27 IntlTestHelper::requireFullIntl($this);
28
29 parent::setUp();
30 }
31
32 protected function getIntlErrorName($errorCode)
33 {
34 return intl_error_name($errorCode);
35 }
36}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Locale/AbstractLocaleTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Locale/AbstractLocaleTest.php
new file mode 100644
index 00000000..08569fad
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Locale/AbstractLocaleTest.php
@@ -0,0 +1,29 @@
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\Tests\Locale;
13
14/**
15 * Test case for Locale implementations.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19abstract class AbstractLocaleTest extends \PHPUnit_Framework_TestCase
20{
21 public function testSetDefault()
22 {
23 $this->call('setDefault', 'en_GB');
24
25 $this->assertSame('en_GB', $this->call('getDefault'));
26 }
27
28 abstract protected function call($methodName);
29}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Locale/LocaleTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Locale/LocaleTest.php
new file mode 100644
index 00000000..7e957187
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Locale/LocaleTest.php
@@ -0,0 +1,159 @@
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\Tests\Locale;
13
14class LocaleTest extends AbstractLocaleTest
15{
16 /**
17 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
18 */
19 public function testAcceptFromHttp()
20 {
21 $this->call('acceptFromHttp', 'pt-br,en-us;q=0.7,en;q=0.5');
22 }
23
24 /**
25 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
26 */
27 public function testComposeLocale()
28 {
29 $subtags = array(
30 'language' => 'pt',
31 'script' => 'Latn',
32 'region' => 'BR'
33 );
34 $this->call('composeLocale', $subtags);
35 }
36
37 /**
38 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
39 */
40 public function testFilterMatches()
41 {
42 $this->call('filterMatches', 'pt-BR', 'pt-BR');
43 }
44
45 /**
46 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
47 */
48 public function testGetAllVariants()
49 {
50 $this->call('getAllVariants', 'pt_BR_Latn');
51 }
52
53 /**
54 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
55 */
56 public function testGetDisplayLanguage()
57 {
58 $this->call('getDisplayLanguage', 'pt-Latn-BR', 'en');
59 }
60
61 /**
62 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
63 */
64 public function testGetDisplayName()
65 {
66 $this->call('getDisplayName', 'pt-Latn-BR', 'en');
67 }
68
69 /**
70 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
71 */
72 public function testGetDisplayRegion()
73 {
74 $this->call('getDisplayRegion', 'pt-Latn-BR', 'en');
75 }
76
77 /**
78 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
79 */
80 public function testGetDisplayScript()
81 {
82 $this->call('getDisplayScript', 'pt-Latn-BR', 'en');
83 }
84
85 /**
86 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
87 */
88 public function testGetDisplayVariant()
89 {
90 $this->call('getDisplayVariant', 'pt-Latn-BR', 'en');
91 }
92
93 /**
94 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
95 */
96 public function testGetKeywords()
97 {
98 $this->call('getKeywords', 'pt-BR@currency=BRL');
99 }
100
101 /**
102 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
103 */
104 public function testGetPrimaryLanguage()
105 {
106 $this->call('getPrimaryLanguage', 'pt-Latn-BR');
107 }
108
109 /**
110 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
111 */
112 public function testGetRegion()
113 {
114 $this->call('getRegion', 'pt-Latn-BR');
115 }
116
117 /**
118 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
119 */
120 public function testGetScript()
121 {
122 $this->call('getScript', 'pt-Latn-BR');
123 }
124
125 /**
126 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
127 */
128 public function testLookup()
129 {
130 $langtag = array(
131 'pt-Latn-BR',
132 'pt-BR'
133 );
134 $this->call('lookup', $langtag, 'pt-BR-x-priv1');
135 }
136
137 /**
138 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
139 */
140 public function testParseLocale()
141 {
142 $this->call('parseLocale', 'pt-Latn-BR');
143 }
144
145 /**
146 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
147 */
148 public function testSetDefault()
149 {
150 $this->call('setDefault', 'pt_BR');
151 }
152
153 protected function call($methodName)
154 {
155 $args = array_slice(func_get_args(), 1);
156
157 return call_user_func_array(array('Symfony\Component\Intl\Locale\Locale', $methodName), $args);
158 }
159}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Locale/Verification/LocaleTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Locale/Verification/LocaleTest.php
new file mode 100644
index 00000000..39d4f3cb
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Locale/Verification/LocaleTest.php
@@ -0,0 +1,38 @@
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\Tests\Locale\Verification;
13
14use Symfony\Component\Intl\Tests\Locale\AbstractLocaleTest;
15use Symfony\Component\Intl\Util\IntlTestHelper;
16
17/**
18 * Verifies that {@link AbstractLocaleTest} matches the behavior of the
19 * {@link Locale} class with a specific version of ICU.
20 *
21 * @author Bernhard Schussek <bschussek@gmail.com>
22 */
23class LocaleTest extends AbstractLocaleTest
24{
25 protected function setUp()
26 {
27 IntlTestHelper::requireFullIntl($this);
28
29 parent::setUp();
30 }
31
32 protected function call($methodName)
33 {
34 $args = array_slice(func_get_args(), 1);
35
36 return call_user_func_array(array('Locale', $methodName), $args);
37 }
38}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php
new file mode 100644
index 00000000..ad5581b4
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php
@@ -0,0 +1,707 @@
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\Tests\NumberFormatter;
13
14use Symfony\Component\Intl\Globals\IntlGlobals;
15use Symfony\Component\Intl\Intl;
16use Symfony\Component\Intl\Locale;
17use Symfony\Component\Intl\NumberFormatter\NumberFormatter;
18use Symfony\Component\Intl\Util\IntlTestHelper;
19
20/**
21 * Note that there are some values written like -2147483647 - 1. This is the lower 32bit int max and is a known
22 * behavior of PHP.
23 */
24abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase
25{
26 /**
27 * @dataProvider formatCurrencyWithDecimalStyleProvider
28 */
29 public function testFormatCurrencyWithDecimalStyle($value, $currency, $expected)
30 {
31 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
32 $this->assertEquals($expected, $formatter->formatCurrency($value, $currency));
33 }
34
35 public function formatCurrencyWithDecimalStyleProvider()
36 {
37 return array(
38 array(100, 'ALL', '100'),
39 array(100, 'BRL', '100.00'),
40 array(100, 'CRC', '100'),
41 array(100, 'JPY', '100'),
42 array(100, 'CHF', '100'),
43 array(-100, 'ALL', '-100'),
44 array(-100, 'BRL', '-100'),
45 array(-100, 'CRC', '-100'),
46 array(-100, 'JPY', '-100'),
47 array(-100, 'CHF', '-100'),
48 array(1000.12, 'ALL', '1,000.12'),
49 array(1000.12, 'BRL', '1,000.12'),
50 array(1000.12, 'CRC', '1,000.12'),
51 array(1000.12, 'JPY', '1,000.12'),
52 array(1000.12, 'CHF', '1,000.12')
53 );
54 }
55
56 /**
57 * @dataProvider formatCurrencyWithCurrencyStyleProvider
58 */
59 public function testFormatCurrencyWithCurrencyStyle($value, $currency, $expected)
60 {
61 $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY);
62 $this->assertEquals($expected, $formatter->formatCurrency($value, $currency));
63 }
64
65 public function formatCurrencyWithCurrencyStyleProvider()
66 {
67 return array(
68 array(100, 'ALL', 'ALL100'),
69 array(-100, 'ALL', '(ALL100)'),
70 array(1000.12, 'ALL', 'ALL1,000'),
71
72 array(100, 'JPY', 'Â¥100'),
73 array(-100, 'JPY', '(Â¥100)'),
74 array(1000.12, 'JPY', 'Â¥1,000'),
75
76 array(100, 'EUR', '€100.00'),
77 array(-100, 'EUR', '(€100.00)'),
78 array(1000.12, 'EUR', '€1,000.12'),
79 );
80 }
81
82 /**
83 * @dataProvider formatCurrencyWithCurrencyStyleCostaRicanColonsRoundingProvider
84 */
85 public function testFormatCurrencyWithCurrencyStyleCostaRicanColonsRounding($value, $currency, $symbol, $expected)
86 {
87 $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY);
88 $this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency));
89 }
90
91 public function formatCurrencyWithCurrencyStyleCostaRicanColonsRoundingProvider()
92 {
93 return array(
94 array(100, 'CRC', 'CRC', '%s100'),
95 array(-100, 'CRC', 'CRC', '(%s100)'),
96 array(1000.12, 'CRC', 'CRC', '%s1,000'),
97 );
98 }
99
100 /**
101 * @dataProvider formatCurrencyWithCurrencyStyleBrazilianRealRoundingProvider
102 */
103 public function testFormatCurrencyWithCurrencyStyleBrazilianRealRounding($value, $currency, $symbol, $expected)
104 {
105 $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY);
106 $this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency));
107 }
108
109 public function formatCurrencyWithCurrencyStyleBrazilianRealRoundingProvider()
110 {
111 return array(
112 array(100, 'BRL', 'R', '%s$100.00'),
113 array(-100, 'BRL', 'R', '(%s$100.00)'),
114 array(1000.12, 'BRL', 'R', '%s$1,000.12'),
115
116 // Rounding checks
117 array(1000.121, 'BRL', 'R', '%s$1,000.12'),
118 array(1000.123, 'BRL', 'R', '%s$1,000.12'),
119 array(1000.125, 'BRL', 'R', '%s$1,000.12'),
120 array(1000.127, 'BRL', 'R', '%s$1,000.13'),
121 array(1000.129, 'BRL', 'R', '%s$1,000.13'),
122 array(11.50999, 'BRL', 'R', '%s$11.51'),
123 array(11.9999464, 'BRL', 'R', '%s$12.00')
124 );
125 }
126
127 /**
128 * @dataProvider formatCurrencyWithCurrencyStyleSwissRoundingProvider
129 */
130 public function testFormatCurrencyWithCurrencyStyleSwissRounding($value, $currency, $symbol, $expected)
131 {
132 $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY);
133 $this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency));
134 }
135
136 public function formatCurrencyWithCurrencyStyleSwissRoundingProvider()
137 {
138 return array(
139 array(100, 'CHF', 'CHF', '%s100.00'),
140 array(-100, 'CHF', 'CHF', '(%s100.00)'),
141 array(1000.12, 'CHF', 'CHF', '%s1,000.10'),
142 array('1000.12', 'CHF', 'CHF', '%s1,000.10'),
143
144 // Rounding checks
145 array(1000.121, 'CHF', 'CHF', '%s1,000.10'),
146 array(1000.123, 'CHF', 'CHF', '%s1,000.10'),
147 array(1000.125, 'CHF', 'CHF', '%s1,000.10'),
148 array(1000.127, 'CHF', 'CHF', '%s1,000.15'),
149 array(1000.129, 'CHF', 'CHF', '%s1,000.15'),
150
151 array(1200000.00, 'CHF', 'CHF', '%s1,200,000.00'),
152 array(1200000.1, 'CHF', 'CHF', '%s1,200,000.10'),
153 array(1200000.10, 'CHF', 'CHF', '%s1,200,000.10'),
154 array(1200000.101, 'CHF', 'CHF', '%s1,200,000.10')
155 );
156 }
157
158 public function testFormat()
159 {
160 $errorCode = IntlGlobals::U_ZERO_ERROR;
161 $errorMessage = 'U_ZERO_ERROR';
162
163 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
164 $this->assertSame('9.555', $formatter->format(9.555));
165
166 $this->assertSame($errorMessage, $this->getIntlErrorMessage());
167 $this->assertSame($errorCode, $this->getIntlErrorCode());
168 $this->assertFalse($this->isIntlFailure($this->getIntlErrorCode()));
169 $this->assertSame($errorMessage, $formatter->getErrorMessage());
170 $this->assertSame($errorCode, $formatter->getErrorCode());
171 $this->assertFalse($this->isIntlFailure($formatter->getErrorCode()));
172 }
173
174 public function testFormatWithCurrencyStyle()
175 {
176 $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY);
177 $this->assertEquals('¤1.00', $formatter->format(1));
178 }
179
180 /**
181 * @dataProvider formatTypeInt32Provider
182 */
183 public function testFormatTypeInt32($formatter, $value, $expected, $message = '')
184 {
185 $formattedValue = $formatter->format($value, NumberFormatter::TYPE_INT32);
186 $this->assertEquals($expected, $formattedValue, $message);
187 }
188
189 public function formatTypeInt32Provider()
190 {
191 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
192
193 $message = '->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range.';
194
195 return array(
196 array($formatter, 1, '1'),
197 array($formatter, 1.1, '1'),
198 array($formatter, 2147483648, '-2,147,483,648', $message),
199 array($formatter, -2147483649, '2,147,483,647', $message),
200 );
201 }
202
203 /**
204 * @dataProvider formatTypeInt32WithCurrencyStyleProvider
205 */
206 public function testFormatTypeInt32WithCurrencyStyle($formatter, $value, $expected, $message = '')
207 {
208 $formattedValue = $formatter->format($value, NumberFormatter::TYPE_INT32);
209 $this->assertEquals($expected, $formattedValue, $message);
210 }
211
212 public function formatTypeInt32WithCurrencyStyleProvider()
213 {
214 $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY);
215
216 $message = '->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range.';
217
218 return array(
219 array($formatter, 1, '¤1.00'),
220 array($formatter, 1.1, '¤1.00'),
221 array($formatter, 2147483648, '(¤2,147,483,648.00)', $message),
222 array($formatter, -2147483649, '¤2,147,483,647.00', $message)
223 );
224 }
225
226 /**
227 * The parse() method works differently with integer out of the 32 bit range. format() works fine.
228 * @dataProvider formatTypeInt64Provider
229 */
230 public function testFormatTypeInt64($formatter, $value, $expected)
231 {
232 $formattedValue = $formatter->format($value, NumberFormatter::TYPE_INT64);
233 $this->assertEquals($expected, $formattedValue);
234 }
235
236 public function formatTypeInt64Provider()
237 {
238 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
239
240 return array(
241 array($formatter, 1, '1'),
242 array($formatter, 1.1, '1'),
243 array($formatter, 2147483648, '2,147,483,648'),
244 array($formatter, -2147483649, '-2,147,483,649'),
245 );
246 }
247
248 /**
249 * @dataProvider formatTypeInt64WithCurrencyStyleProvider
250 */
251 public function testFormatTypeInt64WithCurrencyStyle($formatter, $value, $expected)
252 {
253 $formattedValue = $formatter->format($value, NumberFormatter::TYPE_INT64);
254 $this->assertEquals($expected, $formattedValue);
255 }
256
257 public function formatTypeInt64WithCurrencyStyleProvider()
258 {
259 $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY);
260
261 return array(
262 array($formatter, 1, '¤1.00'),
263 array($formatter, 1.1, '¤1.00'),
264 array($formatter, 2147483648, '¤2,147,483,648.00'),
265 array($formatter, -2147483649, '(¤2,147,483,649.00)')
266 );
267 }
268
269 /**
270 * @dataProvider formatTypeDoubleProvider
271 */
272 public function testFormatTypeDouble($formatter, $value, $expected)
273 {
274 $formattedValue = $formatter->format($value, NumberFormatter::TYPE_DOUBLE);
275 $this->assertEquals($expected, $formattedValue);
276 }
277
278 public function formatTypeDoubleProvider()
279 {
280 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
281
282 return array(
283 array($formatter, 1, '1'),
284 array($formatter, 1.1, '1.1'),
285 );
286 }
287
288 /**
289 * @dataProvider formatTypeDoubleWithCurrencyStyleProvider
290 */
291 public function testFormatTypeDoubleWithCurrencyStyle($formatter, $value, $expected)
292 {
293 $formattedValue = $formatter->format($value, NumberFormatter::TYPE_DOUBLE);
294 $this->assertEquals($expected, $formattedValue);
295 }
296
297 public function formatTypeDoubleWithCurrencyStyleProvider()
298 {
299 $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY);
300
301 return array(
302 array($formatter, 1, '¤1.00'),
303 array($formatter, 1.1, '¤1.10'),
304 );
305 }
306
307 /**
308 * @dataProvider formatTypeCurrencyProvider
309 * @expectedException \PHPUnit_Framework_Error_Warning
310 */
311 public function testFormatTypeCurrency($formatter, $value)
312 {
313 $formatter->format($value, NumberFormatter::TYPE_CURRENCY);
314 }
315
316 /**
317 * @dataProvider formatTypeCurrencyProvider
318 */
319 public function testFormatTypeCurrencyReturn($formatter, $value)
320 {
321 $this->assertFalse(@$formatter->format($value, NumberFormatter::TYPE_CURRENCY));
322 }
323
324 public function formatTypeCurrencyProvider()
325 {
326 $df = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
327 $cf = $this->getNumberFormatter('en', NumberFormatter::CURRENCY);
328
329 return array(
330 array($df, 1),
331 array($cf, 1),
332 );
333 }
334
335 /**
336 * @dataProvider formatFractionDigitsProvider
337 */
338 public function testFormatFractionDigits($value, $expected, $fractionDigits = null, $expectedFractionDigits = 1)
339 {
340 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
341
342 if (null !== $fractionDigits) {
343 $attributeRet = $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, $fractionDigits);
344 }
345
346 $formattedValue = $formatter->format($value);
347 $this->assertSame($expected, $formattedValue);
348 $this->assertSame($expectedFractionDigits, $formatter->getAttribute(NumberFormatter::FRACTION_DIGITS));
349
350 if (isset($attributeRet)) {
351 $this->assertTrue($attributeRet);
352 }
353 }
354
355 public function formatFractionDigitsProvider()
356 {
357 return array(
358 array(1.123, '1.123', null, 0),
359 array(1.123, '1', 0, 0),
360 array(1.123, '1.1', 1, 1),
361 array(1.123, '1.12', 2, 2),
362 array(1.123, '1', -1, 0),
363 array(1.123, '1', 'abc', 0)
364 );
365 }
366
367 /**
368 * @dataProvider formatGroupingUsedProvider
369 */
370 public function testFormatGroupingUsed($value, $expected, $groupingUsed = null, $expectedGroupingUsed = 1)
371 {
372 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
373
374 if (null !== $groupingUsed) {
375 $attributeRet = $formatter->setAttribute(NumberFormatter::GROUPING_USED, $groupingUsed);
376 }
377
378 $formattedValue = $formatter->format($value);
379 $this->assertSame($expected, $formattedValue);
380 $this->assertSame($expectedGroupingUsed, $formatter->getAttribute(NumberFormatter::GROUPING_USED));
381
382 if (isset($attributeRet)) {
383 $this->assertTrue($attributeRet);
384 }
385 }
386
387 public function formatGroupingUsedProvider()
388 {
389 return array(
390 array(1000, '1,000', null, 1),
391 array(1000, '1000', 0, 0),
392 array(1000, '1,000', 1, 1),
393 array(1000, '1,000', 2, 1),
394 array(1000, '1000', 'abc', 0),
395 array(1000, '1,000', -1, 1),
396 );
397 }
398
399 /**
400 * @dataProvider formatRoundingModeRoundHalfUpProvider
401 */
402 public function testFormatRoundingModeHalfUp($value, $expected)
403 {
404 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
405 $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, 2);
406
407 $formatter->setAttribute(NumberFormatter::ROUNDING_MODE, NumberFormatter::ROUND_HALFUP);
408 $this->assertSame($expected, $formatter->format($value), '->format() with ROUND_HALFUP rounding mode.');
409 }
410
411 public function formatRoundingModeRoundHalfUpProvider()
412 {
413 // The commented value is differently rounded by intl's NumberFormatter in 32 and 64 bit architectures
414 return array(
415 array(1.121, '1.12'),
416 array(1.123, '1.12'),
417 // array(1.125, '1.13'),
418 array(1.127, '1.13'),
419 array(1.129, '1.13'),
420 );
421 }
422
423 /**
424 * @dataProvider formatRoundingModeRoundHalfDownProvider
425 */
426 public function testFormatRoundingModeHalfDown($value, $expected)
427 {
428 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
429 $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, 2);
430
431 $formatter->setAttribute(NumberFormatter::ROUNDING_MODE, NumberFormatter::ROUND_HALFDOWN);
432 $this->assertSame($expected, $formatter->format($value), '->format() with ROUND_HALFDOWN rounding mode.');
433 }
434
435 public function formatRoundingModeRoundHalfDownProvider()
436 {
437 return array(
438 array(1.121, '1.12'),
439 array(1.123, '1.12'),
440 array(1.125, '1.12'),
441 array(1.127, '1.13'),
442 array(1.129, '1.13'),
443 );
444 }
445
446 /**
447 * @dataProvider formatRoundingModeRoundHalfEvenProvider
448 */
449 public function testFormatRoundingModeHalfEven($value, $expected)
450 {
451 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
452 $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, 2);
453
454 $formatter->setAttribute(NumberFormatter::ROUNDING_MODE, NumberFormatter::ROUND_HALFEVEN);
455 $this->assertSame($expected, $formatter->format($value), '->format() with ROUND_HALFEVEN rounding mode.');
456 }
457
458 public function formatRoundingModeRoundHalfEvenProvider()
459 {
460 return array(
461 array(1.121, '1.12'),
462 array(1.123, '1.12'),
463 array(1.125, '1.12'),
464 array(1.127, '1.13'),
465 array(1.129, '1.13'),
466 );
467 }
468
469 public function testGetLocale()
470 {
471 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
472 $this->assertEquals('en', $formatter->getLocale());
473 }
474
475 /**
476 * @dataProvider parseProvider
477 */
478 public function testParse($value, $expected, $message = '')
479 {
480 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
481 $parsedValue = $formatter->parse($value, NumberFormatter::TYPE_DOUBLE);
482 $this->assertSame($expected, $parsedValue, $message);
483
484 if ($expected === false) {
485 $errorCode = IntlGlobals::U_PARSE_ERROR;
486 $errorMessage = 'Number parsing failed: U_PARSE_ERROR';
487 } else {
488 $errorCode = IntlGlobals::U_ZERO_ERROR;
489 $errorMessage = 'U_ZERO_ERROR';
490 }
491
492 $this->assertSame($errorMessage, $this->getIntlErrorMessage());
493 $this->assertSame($errorCode, $this->getIntlErrorCode());
494 $this->assertSame($errorCode !== 0, $this->isIntlFailure($this->getIntlErrorCode()));
495 $this->assertSame($errorMessage, $formatter->getErrorMessage());
496 $this->assertSame($errorCode, $formatter->getErrorCode());
497 $this->assertSame($errorCode !== 0, $this->isIntlFailure($formatter->getErrorCode()));
498 }
499
500 public function parseProvider()
501 {
502 return array(
503 array('prefix1', false, '->parse() does not parse a number with a string prefix.'),
504 array('1suffix', (float) 1, '->parse() parses a number with a string suffix.'),
505 );
506 }
507
508 /**
509 * @expectedException \PHPUnit_Framework_Error_Warning
510 */
511 public function testParseTypeDefault()
512 {
513 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
514 $formatter->parse('1', NumberFormatter::TYPE_DEFAULT);
515 }
516
517 /**
518 * @dataProvider parseTypeInt32Provider
519 */
520 public function testParseTypeInt32($value, $expected, $message = '')
521 {
522 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
523 $parsedValue = $formatter->parse($value, NumberFormatter::TYPE_INT32);
524 $this->assertSame($expected, $parsedValue);
525 }
526
527 public function parseTypeInt32Provider()
528 {
529 return array(
530 array('1', 1),
531 array('1.1', 1),
532 array('2,147,483,647', 2147483647),
533 array('-2,147,483,648', -2147483647 - 1),
534 array('2,147,483,648', false, '->parse() TYPE_INT32 returns false when the number is greater than the integer positive range.'),
535 array('-2,147,483,649', false, '->parse() TYPE_INT32 returns false when the number is greater than the integer negative range.')
536 );
537 }
538
539 public function testParseTypeInt64With32BitIntegerInPhp32Bit()
540 {
541 IntlTestHelper::require32Bit($this);
542
543 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
544
545 $parsedValue = $formatter->parse('2,147,483,647', NumberFormatter::TYPE_INT64);
546 $this->assertInternalType('integer', $parsedValue);
547 $this->assertEquals(2147483647, $parsedValue);
548
549 $parsedValue = $formatter->parse('-2,147,483,648', NumberFormatter::TYPE_INT64);
550
551 // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4
552 // The negative PHP_INT_MAX was being converted to float
553 if (
554 (version_compare(PHP_VERSION, '5.4.0', '<') && version_compare(PHP_VERSION, '5.3.14', '>=')) ||
555 version_compare(PHP_VERSION, '5.4.4', '>=')
556 ) {
557 $this->assertInternalType('int', $parsedValue);
558 } else {
559 $this->assertInternalType('float', $parsedValue);
560 }
561
562 $this->assertEquals(-2147483648, $parsedValue);
563 }
564
565 public function testParseTypeInt64With32BitIntegerInPhp64Bit()
566 {
567 IntlTestHelper::require64Bit($this);
568
569 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
570
571 $parsedValue = $formatter->parse('2,147,483,647', NumberFormatter::TYPE_INT64);
572 $this->assertInternalType('integer', $parsedValue);
573 $this->assertEquals(2147483647, $parsedValue);
574
575 $parsedValue = $formatter->parse('-2,147,483,648', NumberFormatter::TYPE_INT64);
576 $this->assertInternalType('integer', $parsedValue);
577 $this->assertEquals(-2147483647 - 1, $parsedValue);
578 }
579
580 /**
581 * If PHP is compiled in 32bit mode, the returned value for a 64bit integer are float numbers.
582 */
583 public function testParseTypeInt64With64BitIntegerInPhp32Bit()
584 {
585 IntlTestHelper::require32Bit($this);
586
587 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
588
589 // int 64 using only 32 bit range strangeness
590 $parsedValue = $formatter->parse('2,147,483,648', NumberFormatter::TYPE_INT64);
591 $this->assertInternalType('float', $parsedValue);
592 $this->assertEquals(2147483648, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range.');
593
594 $parsedValue = $formatter->parse('-2,147,483,649', NumberFormatter::TYPE_INT64);
595 $this->assertInternalType('float', $parsedValue);
596 $this->assertEquals(-2147483649, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range.');
597 }
598
599 /**
600 * If PHP is compiled in 64bit mode, the returned value for a 64bit integer are 32bit integer numbers.
601 */
602 public function testParseTypeInt64With64BitIntegerInPhp64Bit()
603 {
604 IntlTestHelper::require64Bit($this);
605
606 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
607
608 $parsedValue = $formatter->parse('2,147,483,648', NumberFormatter::TYPE_INT64);
609 $this->assertInternalType('integer', $parsedValue);
610
611 // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4
612 // A 32 bit integer was being generated instead of a 64 bit integer
613 if (
614 (version_compare(PHP_VERSION, '5.3.14', '<')) ||
615 (version_compare(PHP_VERSION, '5.4.0', '>=') && version_compare(PHP_VERSION, '5.4.4', '<'))
616 ) {
617 $this->assertEquals(-2147483648, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range (PHP < 5.3.14 and PHP < 5.4.4).');
618 } else {
619 $this->assertEquals(2147483648, $parsedValue, '->parse() TYPE_INT64 uses true 64 bit integers (PHP >= 5.3.14 and PHP >= 5.4.4).');
620 }
621
622 $parsedValue = $formatter->parse('-2,147,483,649', NumberFormatter::TYPE_INT64);
623 $this->assertInternalType('integer', $parsedValue);
624
625 // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4
626 // A 32 bit integer was being generated instead of a 64 bit integer
627 if (
628 (version_compare(PHP_VERSION, '5.3.14', '<')) ||
629 (version_compare(PHP_VERSION, '5.4.0', '>=') && version_compare(PHP_VERSION, '5.4.4', '<'))
630 ) {
631 $this->assertEquals(2147483647, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range (PHP < 5.3.14 and PHP < 5.4.4).');
632 } else {
633 $this->assertEquals(-2147483649, $parsedValue, '->parse() TYPE_INT64 uses true 64 bit integers (PHP >= 5.3.14 and PHP >= 5.4.4).');
634 }
635 }
636
637 /**
638 * @dataProvider parseTypeDoubleProvider
639 */
640 public function testParseTypeDouble($value, $expectedValue)
641 {
642 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
643 $parsedValue = $formatter->parse($value, NumberFormatter::TYPE_DOUBLE);
644 $this->assertSame($expectedValue, $parsedValue);
645 }
646
647 public function parseTypeDoubleProvider()
648 {
649 return array(
650 array('1', (float) 1),
651 array('1.1', 1.1),
652 array('9,223,372,036,854,775,808', 9223372036854775808),
653 array('-9,223,372,036,854,775,809', -9223372036854775809),
654 );
655 }
656
657 /**
658 * @expectedException \PHPUnit_Framework_Error_Warning
659 */
660 public function testParseTypeCurrency()
661 {
662 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
663 $formatter->parse('1', NumberFormatter::TYPE_CURRENCY);
664 }
665
666 public function testParseWithNullPositionValue()
667 {
668 $position = null;
669 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
670 $formatter->parse('123', NumberFormatter::TYPE_INT32, $position);
671 $this->assertNull($position);
672 }
673
674 public function testParseWithNotNullPositionValue()
675 {
676 $position = 1;
677 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
678 $formatter->parse('123', NumberFormatter::TYPE_DOUBLE, $position);
679 $this->assertEquals(3, $position);
680 }
681
682 /**
683 * @param string $locale
684 * @param null $style
685 * @param null $pattern
686 *
687 * @return \NumberFormatter
688 */
689 abstract protected function getNumberFormatter($locale = 'en', $style = null, $pattern = null);
690
691 /**
692 * @return string
693 */
694 abstract protected function getIntlErrorMessage();
695
696 /**
697 * @return integer
698 */
699 abstract protected function getIntlErrorCode();
700
701 /**
702 * @param integer $errorCode
703 *
704 * @return Boolean
705 */
706 abstract protected function isIntlFailure($errorCode);
707}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php
new file mode 100644
index 00000000..36e89149
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php
@@ -0,0 +1,239 @@
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\Tests\NumberFormatter;
13
14use Symfony\Component\Intl\Globals\IntlGlobals;
15use Symfony\Component\Intl\NumberFormatter\NumberFormatter;
16use Symfony\Component\Intl\Util\IntlTestHelper;
17
18/**
19 * Note that there are some values written like -2147483647 - 1. This is the lower 32bit int max and is a known
20 * behavior of PHP.
21 */
22class NumberFormatterTest extends AbstractNumberFormatterTest
23{
24 protected function setUp()
25 {
26 IntlTestHelper::requireIntl($this);
27
28 parent::setUp();
29 }
30
31 /**
32 * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
33 */
34 public function testConstructorWithUnsupportedLocale()
35 {
36 new NumberFormatter('pt_BR');
37 }
38
39 /**
40 * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
41 */
42 public function testConstructorWithUnsupportedStyle()
43 {
44 new NumberFormatter('en', NumberFormatter::PATTERN_DECIMAL);
45 }
46
47 /**
48 * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException
49 */
50 public function testConstructorWithPatternDifferentThanNull()
51 {
52 new NumberFormatter('en', NumberFormatter::DECIMAL, '');
53 }
54
55 /**
56 * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
57 */
58 public function testSetAttributeWithUnsupportedAttribute()
59 {
60 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
61 $formatter->setAttribute(NumberFormatter::LENIENT_PARSE, null);
62 }
63
64 /**
65 * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
66 */
67 public function testSetAttributeInvalidRoundingMode()
68 {
69 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
70 $formatter->setAttribute(NumberFormatter::ROUNDING_MODE, null);
71 }
72
73 public function testCreate()
74 {
75 $this->assertInstanceOf(
76 '\Symfony\Component\Intl\NumberFormatter\NumberFormatter',
77 NumberFormatter::create('en', NumberFormatter::DECIMAL)
78 );
79 }
80
81 /**
82 * @expectedException \RuntimeException
83 */
84 public function testFormatWithCurrencyStyle()
85 {
86 parent::testFormatWithCurrencyStyle();
87 }
88
89 /**
90 * @dataProvider formatTypeInt32Provider
91 * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
92 */
93 public function testFormatTypeInt32($formatter, $value, $expected, $message = '')
94 {
95 parent::testFormatTypeInt32($formatter, $value, $expected, $message);
96 }
97
98 /**
99 * @dataProvider formatTypeInt32WithCurrencyStyleProvider
100 * @expectedException \Symfony\Component\Intl\Exception\NotImplementedException
101 */
102 public function testFormatTypeInt32WithCurrencyStyle($formatter, $value, $expected, $message = '')
103 {
104 parent::testFormatTypeInt32WithCurrencyStyle($formatter, $value, $expected, $message);
105 }
106
107 /**
108 * @dataProvider formatTypeInt64Provider
109 * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
110 */
111 public function testFormatTypeInt64($formatter, $value, $expected)
112 {
113 parent::testFormatTypeInt64($formatter, $value, $expected);
114 }
115
116 /**
117 * @dataProvider formatTypeInt64WithCurrencyStyleProvider
118 * @expectedException \Symfony\Component\Intl\Exception\NotImplementedException
119 */
120 public function testFormatTypeInt64WithCurrencyStyle($formatter, $value, $expected)
121 {
122 parent::testFormatTypeInt64WithCurrencyStyle($formatter, $value, $expected);
123 }
124
125 /**
126 * @dataProvider formatTypeDoubleProvider
127 * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
128 */
129 public function testFormatTypeDouble($formatter, $value, $expected)
130 {
131 parent::testFormatTypeDouble($formatter, $value, $expected);
132 }
133
134 /**
135 * @dataProvider formatTypeDoubleWithCurrencyStyleProvider
136 * @expectedException \Symfony\Component\Intl\Exception\NotImplementedException
137 */
138 public function testFormatTypeDoubleWithCurrencyStyle($formatter, $value, $expected)
139 {
140 parent::testFormatTypeDoubleWithCurrencyStyle($formatter, $value, $expected);
141 }
142
143 /**
144 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
145 */
146 public function testGetPattern()
147 {
148 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
149 $formatter->getPattern();
150 }
151
152 /**
153 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
154 */
155 public function testGetSymbol()
156 {
157 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
158 $formatter->getSymbol(null);
159 }
160
161 /**
162 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
163 */
164 public function testGetTextAttribute()
165 {
166 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
167 $formatter->getTextAttribute(null);
168 }
169
170 public function testGetErrorCode()
171 {
172 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
173 $this->assertEquals(IntlGlobals::U_ZERO_ERROR, $formatter->getErrorCode());
174 }
175
176 /**
177 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
178 */
179 public function testParseCurrency()
180 {
181 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
182 $formatter->parseCurrency(null, $currency);
183 }
184
185 /**
186 * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException
187 */
188 public function testParseWithNotNullPositionValue()
189 {
190 parent::testParseWithNotNullPositionValue();
191 }
192
193 /**
194 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
195 */
196 public function testSetPattern()
197 {
198 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
199 $formatter->setPattern(null);
200 }
201
202 /**
203 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
204 */
205 public function testSetSymbol()
206 {
207 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
208 $formatter->setSymbol(null, null);
209 }
210
211 /**
212 * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException
213 */
214 public function testSetTextAttribute()
215 {
216 $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
217 $formatter->setTextAttribute(null, null);
218 }
219
220 protected function getNumberFormatter($locale = 'en', $style = null, $pattern = null)
221 {
222 return new NumberFormatter($locale, $style, $pattern);
223 }
224
225 protected function getIntlErrorMessage()
226 {
227 return IntlGlobals::getErrorMessage();
228 }
229
230 protected function getIntlErrorCode()
231 {
232 return IntlGlobals::getErrorCode();
233 }
234
235 protected function isIntlFailure($errorCode)
236 {
237 return IntlGlobals::isFailure($errorCode);
238 }
239}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/NumberFormatter/Verification/NumberFormatterTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/NumberFormatter/Verification/NumberFormatterTest.php
new file mode 100644
index 00000000..28e6fe90
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/NumberFormatter/Verification/NumberFormatterTest.php
@@ -0,0 +1,54 @@
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\Tests\NumberFormatter\Verification;
13
14use Symfony\Component\Intl\Tests\NumberFormatter\AbstractNumberFormatterTest;
15use Symfony\Component\Intl\Util\IntlTestHelper;
16
17/**
18 * Note that there are some values written like -2147483647 - 1. This is the lower 32bit int max and is a known
19 * behavior of PHP.
20 */
21class NumberFormatterTest extends AbstractNumberFormatterTest
22{
23 protected function setUp()
24 {
25 IntlTestHelper::requireFullIntl($this);
26
27 parent::setUp();
28 }
29
30 public function testCreate()
31 {
32 $this->assertInstanceOf('\NumberFormatter', \NumberFormatter::create('en', \NumberFormatter::DECIMAL));
33 }
34
35 protected function getNumberFormatter($locale = 'en', $style = null, $pattern = null)
36 {
37 return new \NumberFormatter($locale, $style, $pattern);
38 }
39
40 protected function getIntlErrorMessage()
41 {
42 return intl_get_error_message();
43 }
44
45 protected function getIntlErrorCode()
46 {
47 return intl_get_error_code();
48 }
49
50 protected function isIntlFailure($errorCode)
51 {
52 return intl_is_failure($errorCode);
53 }
54}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/AbstractBundleTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/AbstractBundleTest.php
new file mode 100644
index 00000000..6b075865
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/AbstractBundleTest.php
@@ -0,0 +1,55 @@
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\Tests\ResourceBundle;
13
14/**
15 * @author Bernhard Schussek <bschussek@gmail.com>
16 */
17class AbstractBundleTest extends \PHPUnit_Framework_TestCase
18{
19 const RES_DIR = '/base/dirName';
20
21 /**
22 * @var \Symfony\Component\Intl\ResourceBundle\AbstractBundle
23 */
24 private $bundle;
25
26 /**
27 * @var \PHPUnit_Framework_MockObject_MockObject
28 */
29 private $reader;
30
31 protected function setUp()
32 {
33 $this->reader = $this->getMock('Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReaderInterface');
34 $this->bundle = $this->getMockForAbstractClass(
35 'Symfony\Component\Intl\ResourceBundle\AbstractBundle',
36 array(self::RES_DIR, $this->reader)
37 );
38
39 $this->bundle->expects($this->any())
40 ->method('getDirectoryName')
41 ->will($this->returnValue('dirName'));
42 }
43
44 public function testGetLocales()
45 {
46 $locales = array('de', 'en', 'fr');
47
48 $this->reader->expects($this->once())
49 ->method('getLocales')
50 ->with(self::RES_DIR)
51 ->will($this->returnValue($locales));
52
53 $this->assertSame($locales, $this->bundle->getLocales());
54 }
55}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/CurrencyBundleTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/CurrencyBundleTest.php
new file mode 100644
index 00000000..b66a6727
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/CurrencyBundleTest.php
@@ -0,0 +1,98 @@
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\Tests\ResourceBundle;
13
14use Symfony\Component\Intl\ResourceBundle\CurrencyBundle;
15
16/**
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class CurrencyBundleTest extends \PHPUnit_Framework_TestCase
20{
21 const RES_DIR = '/base/curr';
22
23 /**
24 * @var CurrencyBundle
25 */
26 private $bundle;
27
28 /**
29 * @var \PHPUnit_Framework_MockObject_MockObject
30 */
31 private $reader;
32
33 protected function setUp()
34 {
35 $this->reader = $this->getMock('Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReaderInterface');
36 $this->bundle = new CurrencyBundle(self::RES_DIR, $this->reader);
37 }
38
39 public function testGetCurrencySymbol()
40 {
41 $this->reader->expects($this->once())
42 ->method('readEntry')
43 ->with(self::RES_DIR, 'en', array('Currencies', 'EUR', 1))
44 ->will($this->returnValue('€'));
45
46 $this->assertSame('€', $this->bundle->getCurrencySymbol('EUR', 'en'));
47 }
48
49 public function testGetCurrencyName()
50 {
51 $this->reader->expects($this->once())
52 ->method('readEntry')
53 ->with(self::RES_DIR, 'en', array('Currencies', 'EUR', 0))
54 ->will($this->returnValue('Euro'));
55
56 $this->assertSame('Euro', $this->bundle->getCurrencyName('EUR', 'en'));
57 }
58
59 public function testGetCurrencyNames()
60 {
61 $sortedCurrencies = array(
62 'USD' => array(0 => 'Dollar'),
63 'EUR' => array(0 => 'Euro'),
64 );
65
66 $this->reader->expects($this->once())
67 ->method('readEntry')
68 ->with(self::RES_DIR, 'en', array('Currencies'))
69 ->will($this->returnValue($sortedCurrencies));
70
71 $sortedNames = array(
72 'USD' => 'Dollar',
73 'EUR' => 'Euro',
74 );
75
76 $this->assertSame($sortedNames, $this->bundle->getCurrencyNames('en'));
77 }
78
79 public function testGetFractionDigits()
80 {
81 $this->reader->expects($this->once())
82 ->method('readEntry')
83 ->with(self::RES_DIR, 'en', array('Currencies', 'EUR', 2))
84 ->will($this->returnValue(123));
85
86 $this->assertSame(123, $this->bundle->getFractionDigits('EUR'));
87 }
88
89 public function testGetRoundingIncrement()
90 {
91 $this->reader->expects($this->once())
92 ->method('readEntry')
93 ->with(self::RES_DIR, 'en', array('Currencies', 'EUR', 3))
94 ->will($this->returnValue(123));
95
96 $this->assertSame(123, $this->bundle->getRoundingIncrement('EUR'));
97 }
98}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/LanguageBundleTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/LanguageBundleTest.php
new file mode 100644
index 00000000..96031fc7
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/LanguageBundleTest.php
@@ -0,0 +1,197 @@
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\Tests\ResourceBundle;
13
14use Symfony\Component\Intl\ResourceBundle\LanguageBundle;
15
16/**
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class LanguageBundleTest extends \PHPUnit_Framework_TestCase
20{
21 const RES_DIR = '/base/lang';
22
23 /**
24 * @var LanguageBundle
25 */
26 private $bundle;
27
28 /**
29 * @var \PHPUnit_Framework_MockObject_MockObject
30 */
31 private $reader;
32
33 protected function setUp()
34 {
35 $this->reader = $this->getMock('Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReaderInterface');
36 $this->bundle = new LanguageBundle(self::RES_DIR, $this->reader);
37 }
38
39 public function testGetLanguageName()
40 {
41 $languages = array(
42 'de' => 'German',
43 'en' => 'English',
44 );
45
46 $this->reader->expects($this->once())
47 ->method('readEntry')
48 ->with(self::RES_DIR, 'en', array('Languages'))
49 ->will($this->returnValue($languages));
50
51 $this->assertSame('German', $this->bundle->getLanguageName('de', null, 'en'));
52 }
53
54 public function testGetLanguageNameWithRegion()
55 {
56 $languages = array(
57 'de' => 'German',
58 'en' => 'English',
59 'en_GB' => 'British English',
60 );
61
62 $this->reader->expects($this->once())
63 ->method('readEntry')
64 ->with(self::RES_DIR, 'en', array('Languages'))
65 ->will($this->returnValue($languages));
66
67 $this->assertSame('British English', $this->bundle->getLanguageName('en', 'GB', 'en'));
68 }
69
70 public function testGetLanguageNameWithUntranslatedRegion()
71 {
72 $languages = array(
73 'de' => 'German',
74 'en' => 'English',
75 );
76
77 $this->reader->expects($this->once())
78 ->method('readEntry')
79 ->with(self::RES_DIR, 'en', array('Languages'))
80 ->will($this->returnValue($languages));
81
82 $this->assertSame('English', $this->bundle->getLanguageName('en', 'US', 'en'));
83 }
84
85 public function testGetLanguageNames()
86 {
87 $sortedLanguages = array(
88 'en' => 'English',
89 'de' => 'German',
90 );
91
92 $this->reader->expects($this->once())
93 ->method('readEntry')
94 ->with(self::RES_DIR, 'en', array('Languages'))
95 ->will($this->returnValue($sortedLanguages));
96
97 $this->assertSame($sortedLanguages, $this->bundle->getLanguageNames('en'));
98 }
99
100 public function testGetScriptName()
101 {
102 $data = array(
103 'Languages' => array(
104 'de' => 'German',
105 'en' => 'English',
106 ),
107 'Scripts' => array(
108 'Latn' => 'latin',
109 'Cyrl' => 'cyrillique',
110 ),
111 );
112
113 $this->reader->expects($this->once())
114 ->method('read')
115 ->with(self::RES_DIR, 'en')
116 ->will($this->returnValue($data));
117
118 $this->assertSame('latin', $this->bundle->getScriptName('Latn', null, 'en'));
119 }
120
121 public function testGetScriptNameIncludedInLanguage()
122 {
123 $data = array(
124 'Languages' => array(
125 'de' => 'German',
126 'en' => 'English',
127 'zh_Hans' => 'Simplified Chinese',
128 ),
129 'Scripts' => array(
130 'Latn' => 'latin',
131 'Cyrl' => 'cyrillique',
132 ),
133 );
134
135 $this->reader->expects($this->once())
136 ->method('read')
137 ->with(self::RES_DIR, 'en')
138 ->will($this->returnValue($data));
139
140 // Null because the script is included in the language anyway
141 $this->assertNull($this->bundle->getScriptName('Hans', 'zh', 'en'));
142 }
143
144 public function testGetScriptNameIncludedInLanguageInBraces()
145 {
146 $data = array(
147 'Languages' => array(
148 'de' => 'German',
149 'en' => 'English',
150 'zh_Hans' => 'Chinese (simplified)',
151 ),
152 'Scripts' => array(
153 'Latn' => 'latin',
154 'Cyrl' => 'cyrillique',
155 ),
156 );
157
158 $this->reader->expects($this->once())
159 ->method('read')
160 ->with(self::RES_DIR, 'en')
161 ->will($this->returnValue($data));
162
163 $this->assertSame('simplified', $this->bundle->getScriptName('Hans', 'zh', 'en'));
164 }
165
166 public function testGetScriptNameNoScriptsBlock()
167 {
168 $data = array(
169 'Languages' => array(
170 'de' => 'German',
171 'en' => 'English',
172 ),
173 );
174
175 $this->reader->expects($this->once())
176 ->method('read')
177 ->with(self::RES_DIR, 'en')
178 ->will($this->returnValue($data));
179
180 $this->assertNull($this->bundle->getScriptName('Latn', null, 'en'));
181 }
182
183 public function testGetScriptNames()
184 {
185 $sortedScripts = array(
186 'Cyrl' => 'cyrillique',
187 'Latn' => 'latin',
188 );
189
190 $this->reader->expects($this->once())
191 ->method('readEntry')
192 ->with(self::RES_DIR, 'en', array('Scripts'))
193 ->will($this->returnValue($sortedScripts));
194
195 $this->assertSame($sortedScripts, $this->bundle->getScriptNames('en'));
196 }
197}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/LocaleBundleTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/LocaleBundleTest.php
new file mode 100644
index 00000000..ddfdc3d2
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/LocaleBundleTest.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\Tests\ResourceBundle;
13
14use Symfony\Component\Intl\ResourceBundle\LocaleBundle;
15
16/**
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class LocaleBundleTest extends \PHPUnit_Framework_TestCase
20{
21 const RES_DIR = '/base/locales';
22
23 /**
24 * @var LocaleBundle
25 */
26 private $bundle;
27
28 /**
29 * @var \PHPUnit_Framework_MockObject_MockObject
30 */
31 private $reader;
32
33 protected function setUp()
34 {
35 $this->reader = $this->getMock('Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReaderInterface');
36 $this->bundle = new LocaleBundle(self::RES_DIR, $this->reader);
37 }
38
39 public function testGetLocaleName()
40 {
41 $this->reader->expects($this->once())
42 ->method('readEntry')
43 ->with(self::RES_DIR, 'en', array('Locales', 'de_AT'))
44 ->will($this->returnValue('German (Austria)'));
45
46 $this->assertSame('German (Austria)', $this->bundle->getLocaleName('de_AT', 'en'));
47 }
48
49 public function testGetLocaleNames()
50 {
51 $sortedLocales = array(
52 'en_IE' => 'English (Ireland)',
53 'en_GB' => 'English (United Kingdom)',
54 'en_US' => 'English (United States)',
55 );
56
57 $this->reader->expects($this->once())
58 ->method('readEntry')
59 ->with(self::RES_DIR, 'en', array('Locales'))
60 ->will($this->returnValue($sortedLocales));
61
62 $this->assertSame($sortedLocales, $this->bundle->getLocaleNames('en'));
63 }
64}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/AbstractBundleReaderTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/AbstractBundleReaderTest.php
new file mode 100644
index 00000000..2da7f90d
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/AbstractBundleReaderTest.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\Tests\ResourceBundle\Reader;
13
14use Symfony\Component\Filesystem\Filesystem;
15
16/**
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class AbstractBundleReaderTest extends \PHPUnit_Framework_TestCase
20{
21 private $directory;
22
23 /**
24 * @var Filesystem
25 */
26 private $filesystem;
27
28 /**
29 * @var \PHPUnit_Framework_MockObject_MockObject
30 */
31 private $reader;
32
33 protected function setUp()
34 {
35 $this->directory = sys_get_temp_dir() . '/AbstractBundleReaderTest/' . rand(1000, 9999);
36 $this->filesystem = new Filesystem();
37 $this->reader = $this->getMockForAbstractClass('Symfony\Component\Intl\ResourceBundle\Reader\AbstractBundleReader');
38
39 $this->filesystem->mkdir($this->directory);
40 }
41
42 protected function tearDown()
43 {
44 $this->filesystem->remove($this->directory);
45 }
46
47 public function testGetLocales()
48 {
49 $this->filesystem->touch($this->directory . '/en.foo');
50 $this->filesystem->touch($this->directory . '/de.foo');
51 $this->filesystem->touch($this->directory . '/fr.foo');
52 $this->filesystem->touch($this->directory . '/bo.txt');
53 $this->filesystem->touch($this->directory . '/gu.bin');
54 $this->filesystem->touch($this->directory . '/s.lol');
55
56 $this->reader->expects($this->any())
57 ->method('getFileExtension')
58 ->will($this->returnValue('foo'));
59
60 $sortedLocales = array('de', 'en', 'fr');
61
62 $this->assertSame($sortedLocales, $this->reader->getLocales($this->directory));
63 }
64}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/BinaryBundleReaderTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/BinaryBundleReaderTest.php
new file mode 100644
index 00000000..3aefbae7
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/BinaryBundleReaderTest.php
@@ -0,0 +1,58 @@
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\Tests\ResourceBundle\Reader;
13
14use Symfony\Component\Intl\ResourceBundle\Reader\BinaryBundleReader;
15use Symfony\Component\Intl\Util\IntlTestHelper;
16
17/**
18 * @author Bernhard Schussek <bschussek@gmail.com>
19 */
20class BinaryBundleReaderTest extends \PHPUnit_Framework_TestCase
21{
22 /**
23 * @var BinaryBundleReader
24 */
25 private $reader;
26
27 protected function setUp()
28 {
29 IntlTestHelper::requireFullIntl($this);
30
31 $this->reader = new BinaryBundleReader();
32 }
33
34 public function testReadReturnsArrayAccess()
35 {
36 $data = $this->reader->read(__DIR__ . '/Fixtures', 'en');
37
38 $this->assertInstanceOf('\ArrayAccess', $data);
39 $this->assertSame('Bar', $data['Foo']);
40 $this->assertFalse(isset($data['ExistsNot']));
41 }
42
43 /**
44 * @expectedException \Symfony\Component\Intl\Exception\RuntimeException
45 */
46 public function testReadFailsIfNonExistingLocale()
47 {
48 $this->reader->read(__DIR__ . '/Fixtures', 'foo');
49 }
50
51 /**
52 * @expectedException \Symfony\Component\Intl\Exception\RuntimeException
53 */
54 public function testReadFailsIfNonExistingDirectory()
55 {
56 $this->reader->read(__DIR__ . '/foo', 'en');
57 }
58}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/NotAFile/en.php/.gitkeep b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/NotAFile/en.php/.gitkeep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/NotAFile/en.php/.gitkeep
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.php
new file mode 100644
index 00000000..f2b06a91
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.php
@@ -0,0 +1,14 @@
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
12return array(
13 'Foo' => 'Bar',
14);
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.res b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.res
new file mode 100644
index 00000000..c78e9045
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.res
Binary files differ
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.txt b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.txt
new file mode 100644
index 00000000..c788e996
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.txt
@@ -0,0 +1,3 @@
1en{
2 Foo{"Bar"}
3}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/PhpBundleReaderTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/PhpBundleReaderTest.php
new file mode 100644
index 00000000..2fee3559
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/PhpBundleReaderTest.php
@@ -0,0 +1,63 @@
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\Tests\ResourceBundle\Reader;
13
14use Symfony\Component\Intl\ResourceBundle\Reader\PhpBundleReader;
15
16/**
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class PhpBundleReaderTest extends \PHPUnit_Framework_TestCase
20{
21 /**
22 * @var PhpBundleReader
23 */
24 private $reader;
25
26 protected function setUp()
27 {
28 $this->reader = new PhpBundleReader();
29 }
30
31 public function testReadReturnsArray()
32 {
33 $data = $this->reader->read(__DIR__ . '/Fixtures', 'en');
34
35 $this->assertTrue(is_array($data));
36 $this->assertSame('Bar', $data['Foo']);
37 $this->assertFalse(isset($data['ExistsNot']));
38 }
39
40 /**
41 * @expectedException \Symfony\Component\Intl\Exception\InvalidArgumentException
42 */
43 public function testReadFailsIfLocaleOtherThanEn()
44 {
45 $this->reader->read(__DIR__ . '/Fixtures', 'foo');
46 }
47
48 /**
49 * @expectedException \Symfony\Component\Intl\Exception\RuntimeException
50 */
51 public function testReadFailsIfNonExistingDirectory()
52 {
53 $this->reader->read(__DIR__ . '/foo', 'en');
54 }
55
56 /**
57 * @expectedException \Symfony\Component\Intl\Exception\RuntimeException
58 */
59 public function testReadFailsIfNotAFile()
60 {
61 $this->reader->read(__DIR__ . '/Fixtures/NotAFile', 'en');
62 }
63}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/StructuredBundleReaderTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/StructuredBundleReaderTest.php
new file mode 100644
index 00000000..600236eb
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/StructuredBundleReaderTest.php
@@ -0,0 +1,223 @@
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\Tests\ResourceBundle\Reader;
13
14use Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReader;
15
16/**
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class StructuredBundleReaderTest extends \PHPUnit_Framework_TestCase
20{
21 const RES_DIR = '/res/dir';
22
23 /**
24 * @var StructuredBundleReader
25 */
26 private $reader;
27
28 /**
29 * @var \PHPUnit_Framework_MockObject_MockObject
30 */
31 private $readerImpl;
32
33 protected function setUp()
34 {
35 $this->readerImpl = $this->getMock('Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReaderInterface');
36 $this->reader = new StructuredBundleReader($this->readerImpl);
37 }
38
39 public function testGetLocales()
40 {
41 $locales = array('en', 'de', 'fr');
42
43 $this->readerImpl->expects($this->once())
44 ->method('getLocales')
45 ->with(self::RES_DIR)
46 ->will($this->returnValue($locales));
47
48 $this->assertSame($locales, $this->reader->getLocales(self::RES_DIR));
49 }
50
51 public function testRead()
52 {
53 $data = array('foo', 'bar');
54
55 $this->readerImpl->expects($this->once())
56 ->method('read')
57 ->with(self::RES_DIR, 'en')
58 ->will($this->returnValue($data));
59
60 $this->assertSame($data, $this->reader->read(self::RES_DIR, 'en'));
61 }
62
63 public function testReadEntryNoParams()
64 {
65 $data = array('foo', 'bar');
66
67 $this->readerImpl->expects($this->once())
68 ->method('read')
69 ->with(self::RES_DIR, 'en')
70 ->will($this->returnValue($data));
71
72 $this->assertSame($data, $this->reader->readEntry(self::RES_DIR, 'en', array()));
73 }
74
75 public function testReadEntryWithParam()
76 {
77 $data = array('Foo' => array('Bar' => 'Baz'));
78
79 $this->readerImpl->expects($this->once())
80 ->method('read')
81 ->with(self::RES_DIR, 'en')
82 ->will($this->returnValue($data));
83
84 $this->assertSame('Baz', $this->reader->readEntry(self::RES_DIR, 'en', array('Foo', 'Bar')));
85 }
86
87 public function testReadEntryWithUnresolvablePath()
88 {
89 $data = array('Foo' => 'Baz');
90
91 $this->readerImpl->expects($this->once())
92 ->method('read')
93 ->with(self::RES_DIR, 'en')
94 ->will($this->returnValue($data));
95
96 $this->assertNull($this->reader->readEntry(self::RES_DIR, 'en', array('Foo', 'Bar')));
97 }
98
99 public function readMergedEntryProvider()
100 {
101 return array(
102 array('foo', null, 'foo'),
103 array(null, 'foo', 'foo'),
104 array(array('foo', 'bar'), null, array('foo', 'bar')),
105 array(array('foo', 'bar'), array(), array('foo', 'bar')),
106 array(null, array('baz'), array('baz')),
107 array(array(), array('baz'), array('baz')),
108 array(array('foo', 'bar'), array('baz'), array('baz', 'foo', 'bar')),
109 );
110 }
111
112 /**
113 * @dataProvider readMergedEntryProvider
114 */
115 public function testReadMergedEntryNoParams($childData, $parentData, $result)
116 {
117 $this->readerImpl->expects($this->at(0))
118 ->method('read')
119 ->with(self::RES_DIR, 'en_GB')
120 ->will($this->returnValue($childData));
121
122 if (null === $childData || is_array($childData)) {
123 $this->readerImpl->expects($this->at(1))
124 ->method('read')
125 ->with(self::RES_DIR, 'en')
126 ->will($this->returnValue($parentData));
127 }
128
129 $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en_GB', array(), true));
130 }
131
132 /**
133 * @dataProvider readMergedEntryProvider
134 */
135 public function testReadMergedEntryWithParams($childData, $parentData, $result)
136 {
137 $this->readerImpl->expects($this->at(0))
138 ->method('read')
139 ->with(self::RES_DIR, 'en_GB')
140 ->will($this->returnValue(array('Foo' => array('Bar' => $childData))));
141
142 if (null === $childData || is_array($childData)) {
143 $this->readerImpl->expects($this->at(1))
144 ->method('read')
145 ->with(self::RES_DIR, 'en')
146 ->will($this->returnValue(array('Foo' => array('Bar' => $parentData))));
147 }
148
149 $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Foo', 'Bar'), true));
150 }
151
152 public function testReadMergedEntryWithUnresolvablePath()
153 {
154 $this->readerImpl->expects($this->at(0))
155 ->method('read')
156 ->with(self::RES_DIR, 'en_GB')
157 ->will($this->returnValue(array('Foo' => 'Baz')));
158
159 $this->readerImpl->expects($this->at(1))
160 ->method('read')
161 ->with(self::RES_DIR, 'en')
162 ->will($this->returnValue(array('Foo' => 'Bar')));
163
164 $this->assertNull($this->reader->readEntry(self::RES_DIR, 'en_GB', array('Foo', 'Bar'), true));
165 }
166
167 public function testReadMergedEntryWithUnresolvablePathInParent()
168 {
169 $this->readerImpl->expects($this->at(0))
170 ->method('read')
171 ->with(self::RES_DIR, 'en_GB')
172 ->will($this->returnValue(array('Foo' => array('Bar' => array('three')))));
173
174 $this->readerImpl->expects($this->at(1))
175 ->method('read')
176 ->with(self::RES_DIR, 'en')
177 ->will($this->returnValue(array('Foo' => 'Bar')));
178
179 $result = array('three');
180
181 $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Foo', 'Bar'), true));
182 }
183
184 public function testReadMergedEntryWithUnresolvablePathInChild()
185 {
186 $this->readerImpl->expects($this->at(0))
187 ->method('read')
188 ->with(self::RES_DIR, 'en_GB')
189 ->will($this->returnValue(array('Foo' => 'Baz')));
190
191 $this->readerImpl->expects($this->at(1))
192 ->method('read')
193 ->with(self::RES_DIR, 'en')
194 ->will($this->returnValue(array('Foo' => array('Bar' => array('one', 'two')))));
195
196 $result = array('one', 'two');
197
198 $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Foo', 'Bar'), true));
199 }
200
201 /**
202 * @dataProvider readMergedEntryProvider
203 */
204 public function testReadMergedEntryWithTraversables($childData, $parentData, $result)
205 {
206 $parentData = is_array($parentData) ? new \ArrayObject($parentData) : $parentData;
207 $childData = is_array($childData) ? new \ArrayObject($childData) : $childData;
208
209 $this->readerImpl->expects($this->at(0))
210 ->method('read')
211 ->with(self::RES_DIR, 'en_GB')
212 ->will($this->returnValue(array('Foo' => array('Bar' => $childData))));
213
214 if (null === $childData || $childData instanceof \ArrayObject) {
215 $this->readerImpl->expects($this->at(1))
216 ->method('read')
217 ->with(self::RES_DIR, 'en')
218 ->will($this->returnValue(array('Foo' => array('Bar' => $parentData))));
219 }
220
221 $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Foo', 'Bar'), true));
222 }
223}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/RegionBundleTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/RegionBundleTest.php
new file mode 100644
index 00000000..ccdf904c
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/RegionBundleTest.php
@@ -0,0 +1,63 @@
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\Tests\ResourceBundle;
13
14use Symfony\Component\Intl\ResourceBundle\RegionBundle;
15
16/**
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class RegionBundleTest extends \PHPUnit_Framework_TestCase
20{
21 const RES_DIR = '/base/region';
22
23 /**
24 * @var RegionBundle
25 */
26 private $bundle;
27
28 /**
29 * @var \PHPUnit_Framework_MockObject_MockObject
30 */
31 private $reader;
32
33 protected function setUp()
34 {
35 $this->reader = $this->getMock('Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReaderInterface');
36 $this->bundle = new RegionBundle(self::RES_DIR, $this->reader);
37 }
38
39 public function testGetCountryName()
40 {
41 $this->reader->expects($this->once())
42 ->method('readEntry')
43 ->with(self::RES_DIR, 'en', array('Countries', 'AT'))
44 ->will($this->returnValue('Austria'));
45
46 $this->assertSame('Austria', $this->bundle->getCountryName('AT', 'en'));
47 }
48
49 public function testGetCountryNames()
50 {
51 $sortedCountries = array(
52 'AT' => 'Austria',
53 'DE' => 'Germany',
54 );
55
56 $this->reader->expects($this->once())
57 ->method('readEntry')
58 ->with(self::RES_DIR, 'en', array('Countries'))
59 ->will($this->returnValue($sortedCountries));
60
61 $this->assertSame($sortedCountries, $this->bundle->getCountryNames('en'));
62 }
63}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Util/RingBufferTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Util/RingBufferTest.php
new file mode 100644
index 00000000..d6f7d8a0
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Util/RingBufferTest.php
@@ -0,0 +1,101 @@
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\Tests\ResourceBundle\Util;
13
14use Symfony\Component\Intl\ResourceBundle\Util\RingBuffer;
15
16/**
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class RingBufferTest extends \PHPUnit_Framework_TestCase
20{
21 /**
22 * @var RingBuffer
23 */
24 private $buffer;
25
26 protected function setUp()
27 {
28 $this->buffer = new RingBuffer(2);
29 }
30
31 public function testWriteWithinBuffer()
32 {
33 $this->buffer[0] = 'foo';
34 $this->buffer['bar'] = 'baz';
35
36 $this->assertTrue(isset($this->buffer[0]));
37 $this->assertTrue(isset($this->buffer['bar']));
38 $this->assertSame('foo', $this->buffer[0]);
39 $this->assertSame('baz', $this->buffer['bar']);
40 }
41
42 public function testWritePastBuffer()
43 {
44 $this->buffer[0] = 'foo';
45 $this->buffer['bar'] = 'baz';
46 $this->buffer[2] = 'bam';
47
48 $this->assertTrue(isset($this->buffer['bar']));
49 $this->assertTrue(isset($this->buffer[2]));
50 $this->assertSame('baz', $this->buffer['bar']);
51 $this->assertSame('bam', $this->buffer[2]);
52 }
53
54 /**
55 * @expectedException \Symfony\Component\Intl\Exception\OutOfBoundsException
56 */
57 public function testReadNonExistingFails()
58 {
59 $this->buffer['foo'];
60 }
61
62 public function testQueryNonExisting()
63 {
64 $this->assertFalse(isset($this->buffer['foo']));
65 }
66
67 public function testUnsetNonExistingSucceeds()
68 {
69 unset($this->buffer['foo']);
70
71 $this->assertFalse(isset($this->buffer['foo']));
72 }
73
74 /**
75 * @expectedException \Symfony\Component\Intl\Exception\OutOfBoundsException
76 */
77 public function testReadOverwrittenFails()
78 {
79 $this->buffer[0] = 'foo';
80 $this->buffer['bar'] = 'baz';
81 $this->buffer[2] = 'bam';
82
83 $this->buffer[0];
84 }
85
86 public function testQueryOverwritten()
87 {
88 $this->assertFalse(isset($this->buffer[0]));
89 }
90
91 public function testUnsetOverwrittenSucceeds()
92 {
93 $this->buffer[0] = 'foo';
94 $this->buffer['bar'] = 'baz';
95 $this->buffer[2] = 'bam';
96
97 unset($this->buffer[0]);
98
99 $this->assertFalse(isset($this->buffer[0]));
100 }
101}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.php
new file mode 100644
index 00000000..1ded57a7
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.php
@@ -0,0 +1,23 @@
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
12return array(
13 'Entry1' => array(
14 'Array' => array(
15 0 => 'foo',
16 1 => 'bar',
17 ),
18 'Integer' => 5,
19 'Boolean' => false,
20 'Float' => 1.23,
21 ),
22 'Entry2' => 'String',
23);
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.res b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.res
new file mode 100644
index 00000000..7c1f71eb
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.res
Binary files differ
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.txt b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.txt
new file mode 100644
index 00000000..0ee0d7f2
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.txt
@@ -0,0 +1,23 @@
1en{
2 Entry1{
3 Array{
4 "foo",
5 "bar",
6 {
7 Key{"value"}
8 },
9 }
10 Integer:int{5}
11 IntVector:intvector{
12 0,
13 1,
14 2,
15 3,
16 }
17 FalseBoolean{"false"}
18 TrueBoolean{"true"}
19 Null{""}
20 Float{"1.23"}
21 }
22 Entry2{"String"}
23}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/PhpBundleWriterTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/PhpBundleWriterTest.php
new file mode 100644
index 00000000..03302834
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/PhpBundleWriterTest.php
@@ -0,0 +1,62 @@
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\Tests\ResourceBundle\Writer;
13
14use Symfony\Component\Filesystem\Filesystem;
15use Symfony\Component\Intl\ResourceBundle\Writer\PhpBundleWriter;
16
17/**
18 * @author Bernhard Schussek <bschussek@gmail.com>
19 */
20class PhpBundleWriterTest extends \PHPUnit_Framework_TestCase
21{
22 /**
23 * @var PhpBundleWriter
24 */
25 private $writer;
26
27 private $directory;
28
29 /**
30 * @var Filesystem
31 */
32 private $filesystem;
33
34 protected function setUp()
35 {
36 $this->writer = new PhpBundleWriter();
37 $this->directory = sys_get_temp_dir() . '/PhpBundleWriterTest/' . rand(1000, 9999);
38 $this->filesystem = new Filesystem();
39
40 $this->filesystem->mkdir($this->directory);
41 }
42
43 protected function tearDown()
44 {
45 $this->filesystem->remove($this->directory);
46 }
47
48 public function testWrite()
49 {
50 $this->writer->write($this->directory, 'en', array(
51 'Entry1' => array(
52 'Array' => array('foo', 'bar'),
53 'Integer' => 5,
54 'Boolean' => false,
55 'Float' => 1.23,
56 ),
57 'Entry2' => 'String',
58 ));
59
60 $this->assertFileEquals(__DIR__ . '/Fixtures/en.php', $this->directory . '/en.php');
61 }
62}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/TextBundleWriterTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/TextBundleWriterTest.php
new file mode 100644
index 00000000..cbe0c8d8
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/TextBundleWriterTest.php
@@ -0,0 +1,67 @@
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\Tests\ResourceBundle\Writer;
13
14use Symfony\Component\Filesystem\Filesystem;
15use Symfony\Component\Intl\ResourceBundle\Writer\TextBundleWriter;
16
17/**
18 * @author Bernhard Schussek <bschussek@gmail.com>
19 *
20 * @see http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt
21 */
22class TextBundleWriterTest extends \PHPUnit_Framework_TestCase
23{
24 /**
25 * @var TextBundleWriter
26 */
27 private $writer;
28
29 private $directory;
30
31 /**
32 * @var Filesystem
33 */
34 private $filesystem;
35
36 protected function setUp()
37 {
38 $this->writer = new TextBundleWriter();
39 $this->directory = sys_get_temp_dir() . '/TextBundleWriterTest/' . rand(1000, 9999);
40 $this->filesystem = new Filesystem();
41
42 $this->filesystem->mkdir($this->directory);
43 }
44
45 protected function tearDown()
46 {
47 $this->filesystem->remove($this->directory);
48 }
49
50 public function testWrite()
51 {
52 $this->writer->write($this->directory, 'en', array(
53 'Entry1' => array(
54 'Array' => array('foo', 'bar', array('Key' => 'value')),
55 'Integer' => 5,
56 'IntVector' => array(0, 1, 2, 3),
57 'FalseBoolean' => false,
58 'TrueBoolean' => true,
59 'Null' => null,
60 'Float' => 1.23,
61 ),
62 'Entry2' => 'String',
63 ));
64
65 $this->assertFileEquals(__DIR__ . '/Fixtures/en.txt', $this->directory . '/en.txt');
66 }
67}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/IcuVersionTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/IcuVersionTest.php
new file mode 100644
index 00000000..d1a7e8c1
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/IcuVersionTest.php
@@ -0,0 +1,111 @@
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\Tests\Util;
13
14use Symfony\Component\Intl\Util\IcuVersion;
15
16/**
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class IcuVersionTest extends \PHPUnit_Framework_TestCase
20{
21 public function normalizeProvider()
22 {
23 return array(
24 array(null, '1', '10'),
25 array(null, '1.2', '12'),
26 array(null, '1.2.3', '12.3'),
27 array(null, '1.2.3.4', '12.3.4'),
28 array(1, '1', '10'),
29 array(1, '1.2', '12'),
30 array(1, '1.2.3', '12'),
31 array(1, '1.2.3.4', '12'),
32 array(2, '1', '10'),
33 array(2, '1.2', '12'),
34 array(2, '1.2.3', '12.3'),
35 array(2, '1.2.3.4', '12.3'),
36 array(3, '1', '10'),
37 array(3, '1.2', '12'),
38 array(3, '1.2.3', '12.3'),
39 array(3, '1.2.3.4', '12.3.4'),
40 );
41 }
42
43 /**
44 * @dataProvider normalizeProvider
45 */
46 public function testNormalize($precision, $version, $result)
47 {
48 $this->assertSame($result, IcuVersion::normalize($version, $precision));
49 }
50
51 public function compareProvider()
52 {
53 return array(
54 array(null, '1', '==', '1', true),
55 array(null, '1.0', '==', '1.1', false),
56 array(null, '1.0.0', '==', '1.0.1', false),
57 array(null, '1.0.0.0', '==', '1.0.0.1', false),
58 array(null, '1.0.0.0.0', '==', '1.0.0.0.1', false),
59
60 array(null, '1', '==', '10', true),
61 array(null, '1.0', '==', '11', false),
62 array(null, '1.0.0', '==', '10.1', false),
63 array(null, '1.0.0.0', '==', '10.0.1', false),
64 array(null, '1.0.0.0.0', '==', '10.0.0.1', false),
65
66 array(1, '1', '==', '1', true),
67 array(1, '1.0', '==', '1.1', false),
68 array(1, '1.0.0', '==', '1.0.1', true),
69 array(1, '1.0.0.0', '==', '1.0.0.1', true),
70 array(1, '1.0.0.0.0', '==', '1.0.0.0.1', true),
71
72 array(1, '1', '==', '10', true),
73 array(1, '1.0', '==', '11', false),
74 array(1, '1.0.0', '==', '10.1', true),
75 array(1, '1.0.0.0', '==', '10.0.1', true),
76 array(1, '1.0.0.0.0', '==', '10.0.0.1', true),
77
78 array(2, '1', '==', '1', true),
79 array(2, '1.0', '==', '1.1', false),
80 array(2, '1.0.0', '==', '1.0.1', false),
81 array(2, '1.0.0.0', '==', '1.0.0.1', true),
82 array(2, '1.0.0.0.0', '==', '1.0.0.0.1', true),
83
84 array(2, '1', '==', '10', true),
85 array(2, '1.0', '==', '11', false),
86 array(2, '1.0.0', '==', '10.1', false),
87 array(2, '1.0.0.0', '==', '10.0.1', true),
88 array(2, '1.0.0.0.0', '==', '10.0.0.1', true),
89
90 array(3, '1', '==', '1', true),
91 array(3, '1.0', '==', '1.1', false),
92 array(3, '1.0.0', '==', '1.0.1', false),
93 array(3, '1.0.0.0', '==', '1.0.0.1', false),
94 array(3, '1.0.0.0.0', '==', '1.0.0.0.1', true),
95
96 array(3, '1', '==', '10', true),
97 array(3, '1.0', '==', '11', false),
98 array(3, '1.0.0', '==', '10.1', false),
99 array(3, '1.0.0.0', '==', '10.0.1', false),
100 array(3, '1.0.0.0.0', '==', '10.0.0.1', true),
101 );
102 }
103
104 /**
105 * @dataProvider compareProvider
106 */
107 public function testCompare($precision, $version1, $operator, $version2, $result)
108 {
109 $this->assertSame($result, IcuVersion::compare($version1, $version2, $operator, $precision));
110 }
111}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/VersionTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/VersionTest.php
new file mode 100644
index 00000000..60cec6c0
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/VersionTest.php
@@ -0,0 +1,87 @@
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\Tests\Util;
13
14use Symfony\Component\Intl\Util\Version;
15
16/**
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class VersionTest extends \PHPUnit_Framework_TestCase
20{
21 public function normalizeProvider()
22 {
23 return array(
24 array(null, '1', '1'),
25 array(null, '1.2', '1.2'),
26 array(null, '1.2.3', '1.2.3'),
27 array(null, '1.2.3.4', '1.2.3.4'),
28 array(1, '1', '1'),
29 array(1, '1.2', '1'),
30 array(1, '1.2.3', '1'),
31 array(1, '1.2.3.4', '1'),
32 array(2, '1', '1'),
33 array(2, '1.2', '1.2'),
34 array(2, '1.2.3', '1.2'),
35 array(2, '1.2.3.4', '1.2'),
36 array(3, '1', '1'),
37 array(3, '1.2', '1.2'),
38 array(3, '1.2.3', '1.2.3'),
39 array(3, '1.2.3.4', '1.2.3'),
40 array(4, '1', '1'),
41 array(4, '1.2', '1.2'),
42 array(4, '1.2.3', '1.2.3'),
43 array(4, '1.2.3.4', '1.2.3.4'),
44 );
45 }
46
47 /**
48 * @dataProvider normalizeProvider
49 */
50 public function testNormalize($precision, $version, $result)
51 {
52 $this->assertSame($result, Version::normalize($version, $precision));
53 }
54
55 public function compareProvider()
56 {
57 return array(
58 array(null, '1', '==', '1', true),
59 array(null, '1.0', '==', '1.1', false),
60 array(null, '1.0.0', '==', '1.0.1', false),
61 array(null, '1.0.0.0', '==', '1.0.0.1', false),
62
63 array(1, '1', '==', '1', true),
64 array(1, '1.0', '==', '1.1', true),
65 array(1, '1.0.0', '==', '1.0.1', true),
66 array(1, '1.0.0.0', '==', '1.0.0.1', true),
67
68 array(2, '1', '==', '1', true),
69 array(2, '1.0', '==', '1.1', false),
70 array(2, '1.0.0', '==', '1.0.1', true),
71 array(2, '1.0.0.0', '==', '1.0.0.1', true),
72
73 array(3, '1', '==', '1', true),
74 array(3, '1.0', '==', '1.1', false),
75 array(3, '1.0.0', '==', '1.0.1', false),
76 array(3, '1.0.0.0', '==', '1.0.0.1', true),
77 );
78 }
79
80 /**
81 * @dataProvider compareProvider
82 */
83 public function testCompare($precision, $version1, $operator, $version2, $result)
84 {
85 $this->assertSame($result, Version::compare($version1, $version2, $operator, $precision));
86 }
87}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Util/IcuVersion.php b/vendor/symfony/intl/Symfony/Component/Intl/Util/IcuVersion.php
new file mode 100644
index 00000000..e305a075
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Util/IcuVersion.php
@@ -0,0 +1,105 @@
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\Util;
13
14/**
15 * Facilitates the comparison of ICU version strings.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class IcuVersion
20{
21 /**
22 * Compares two ICU versions with an operator.
23 *
24 * This method is identical to {@link version_compare()}, except that you
25 * can pass the number of regarded version components in the last argument
26 * $precision.
27 *
28 * Also, a single digit release version and a single digit major version
29 * are contracted to a two digit release version. If no major version
30 * is given, it is substituted by zero.
31 *
32 * Examples:
33 *
34 * IcuVersion::compare('1.2.3', '1.2.4', '==')
35 * // => false
36 *
37 * IcuVersion::compare('1.2.3', '1.2.4', '==', 2)
38 * // => true
39 *
40 * IcuVersion::compare('1.2.3', '12.3', '==')
41 * // => true
42 *
43 * IcuVersion::compare('1', '10', '==')
44 * // => true
45 *
46 * @param string $version1 A version string.
47 * @param string $version2 A version string to compare.
48 * @param string $operator The comparison operator.
49 * @param integer|null $precision The number of components to compare. Pass
50 * NULL to compare the versions unchanged.
51 *
52 * @return Boolean Whether the comparison succeeded.
53 *
54 * @see normalize()
55 */
56 public static function compare($version1, $version2, $operator, $precision = null)
57 {
58 $version1 = self::normalize($version1, $precision);
59 $version2 = self::normalize($version2, $precision);
60
61 return version_compare($version1, $version2, $operator);
62 }
63
64 /**
65 * Normalizes a version string to the number of components given in the
66 * parameter $precision.
67 *
68 * A single digit release version and a single digit major version are
69 * contracted to a two digit release version. If no major version is given,
70 * it is substituted by zero.
71 *
72 * Examples:
73 *
74 * IcuVersion::normalize('1.2.3.4');
75 * // => '12.3.4'
76 *
77 * IcuVersion::normalize('1.2.3.4', 1);
78 * // => '12'
79 *
80 * IcuVersion::normalize('1.2.3.4', 2);
81 * // => '12.3'
82 *
83 * @param string $version An ICU version string.
84 * @param integer|null $precision The number of components to include. Pass
85 * NULL to return the version unchanged.
86 *
87 * @return string|null The normalized ICU version or NULL if it couldn't be
88 * normalized.
89 */
90 public static function normalize($version, $precision)
91 {
92 $version = preg_replace('/^(\d)\.(\d)/', '$1$2', $version);
93
94 if (1 === strlen($version)) {
95 $version .= '0';
96 }
97
98 return Version::normalize($version, $precision);
99 }
100
101 /**
102 * Must not be instantiated.
103 */
104 private function __construct() {}
105}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Util/IntlTestHelper.php b/vendor/symfony/intl/Symfony/Component/Intl/Util/IntlTestHelper.php
new file mode 100644
index 00000000..cace36c6
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Util/IntlTestHelper.php
@@ -0,0 +1,128 @@
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\Util;
13
14use Symfony\Component\Intl\Intl;
15
16/**
17 * Helper class for preparing test cases that rely on the Intl component.
18 *
19 * Any test that tests functionality relying on either the intl classes or
20 * the resource bundle data should call either of the methods
21 * {@link requireIntl()} or {@link requireFullIntl()}. Calling
22 * {@link requireFullIntl()} is only necessary if you use functionality in the
23 * test that is not provided by the stub intl implementation.
24 *
25 * @author Bernhard Schussek <bschussek@gmail.com>
26 */
27class IntlTestHelper
28{
29 /**
30 * Should be called before tests that work fine with the stub implementation.
31 *
32 * @param \PhpUnit_Framework_TestCase $testCase
33 */
34 public static function requireIntl(\PhpUnit_Framework_TestCase $testCase)
35 {
36 // We only run tests if the version is *one specific version*.
37 // This condition is satisfied if
38 //
39 // * the intl extension is loaded with version Intl::getIcuStubVersion()
40 // * the intl extension is not loaded
41
42 if (IcuVersion::compare(Intl::getIcuVersion(), Intl::getIcuStubVersion(), '!=', 1)) {
43 $testCase->markTestSkipped('Please change ICU version to ' . Intl::getIcuStubVersion());
44 }
45
46 if (IcuVersion::compare(Intl::getIcuDataVersion(), Intl::getIcuStubVersion(), '!=', 1)) {
47 $testCase->markTestSkipped('Please change the Icu component to version 1.0.x or 1.' . IcuVersion::normalize(Intl::getIcuStubVersion(), 1) . '.x');
48 }
49
50 // Normalize the default locale in case this is not done explicitly
51 // in the test
52 \Locale::setDefault('en');
53
54 // Consequently, tests will
55 //
56 // * run only for one ICU version (see Intl::getIcuStubVersion())
57 // there is no need to add control structures to your tests that
58 // change the test depending on the ICU version.
59 //
60 // Tests should only rely on functionality that is implemented in the
61 // stub classes.
62 }
63
64 /**
65 * Should be called before tests that require a feature-complete intl
66 * implementation.
67 *
68 * @param \PhpUnit_Framework_TestCase $testCase
69 */
70 public static function requireFullIntl(\PhpUnit_Framework_TestCase $testCase)
71 {
72 // We only run tests if the intl extension is loaded...
73 if (!Intl::isExtensionLoaded()) {
74 $testCase->markTestSkipped('The intl extension is not available.');
75 }
76
77 // ... and only if the version is *one specific version* ...
78 if (IcuVersion::compare(Intl::getIcuVersion(), Intl::getIcuStubVersion(), '!=', 1)) {
79 $testCase->markTestSkipped('Please change ICU version to ' . Intl::getIcuStubVersion());
80 }
81
82 // ... and only if the data in the Icu component matches that version.
83 if (IcuVersion::compare(Intl::getIcuDataVersion(), Intl::getIcuStubVersion(), '!=', 1)) {
84 $testCase->markTestSkipped('Please change the Icu component to version 1.0.x or 1.' . IcuVersion::normalize(Intl::getIcuStubVersion(), 1) . '.x');
85 }
86
87 // Normalize the default locale in case this is not done explicitly
88 // in the test
89 \Locale::setDefault('en');
90
91 // Consequently, tests will
92 //
93 // * run only for one ICU version (see Intl::getIcuStubVersion())
94 // there is no need to add control structures to your tests that
95 // change the test depending on the ICU version.
96 // * always use the C intl classes
97 // * always use the binary resource bundles (any locale is allowed)
98 }
99
100 /**
101 * Skips the test unless the current system has a 32bit architecture.
102 *
103 * @param \PhpUnit_Framework_TestCase $testCase
104 */
105 public static function require32Bit(\PhpUnit_Framework_TestCase $testCase)
106 {
107 if (4 !== PHP_INT_SIZE) {
108 $testCase->markTestSkipped('PHP must be compiled in 32 bit mode to run this test');
109 }
110 }
111
112 /**
113 * Skips the test unless the current system has a 64bit architecture.
114 *
115 * @param \PhpUnit_Framework_TestCase $testCase
116 */
117 public static function require64Bit(\PhpUnit_Framework_TestCase $testCase)
118 {
119 if (8 !== PHP_INT_SIZE) {
120 $testCase->markTestSkipped('PHP must be compiled in 64 bit mode to run this test');
121 }
122 }
123
124 /**
125 * Must not be instantiated.
126 */
127 private function __construct() {}
128}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Util/SvnCommit.php b/vendor/symfony/intl/Symfony/Component/Intl/Util/SvnCommit.php
new file mode 100644
index 00000000..483d92bc
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Util/SvnCommit.php
@@ -0,0 +1,66 @@
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\Util;
13
14/**
15 * An SVN commit.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class SvnCommit
20{
21 /**
22 * @var \SimpleXMLElement
23 */
24 private $svnInfo;
25
26 /**
27 * Creates a commit from the given "svn info" data.
28 *
29 * @param \SimpleXMLElement $svnInfo The XML result from the "svn info"
30 * command.
31 */
32 public function __construct(\SimpleXMLElement $svnInfo)
33 {
34 $this->svnInfo = $svnInfo;
35 }
36
37 /**
38 * Returns the revision of the commit.
39 *
40 * @return string The revision of the commit.
41 */
42 public function getRevision()
43 {
44 return (string) $this->svnInfo['revision'];
45 }
46
47 /**
48 * Returns the author of the commit.
49 *
50 * @return string The author name.
51 */
52 public function getAuthor()
53 {
54 return (string) $this->svnInfo->author;
55 }
56
57 /**
58 * Returns the date of the commit.
59 *
60 * @return string The commit date.
61 */
62 public function getDate()
63 {
64 return (string) $this->svnInfo->date;
65 }
66}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Util/SvnRepository.php b/vendor/symfony/intl/Symfony/Component/Intl/Util/SvnRepository.php
new file mode 100644
index 00000000..fb44e3c6
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Util/SvnRepository.php
@@ -0,0 +1,141 @@
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\Util;
13
14use Symfony\Component\Filesystem\Filesystem;
15use Symfony\Component\Intl\Exception\RuntimeException;
16
17/**
18 * A SVN repository containing ICU data.
19 *
20 * @author Bernhard Schussek <bschussek@gmail.com>
21 */
22class SvnRepository
23{
24 /**
25 * @var string The path to the repository.
26 */
27 private $path;
28
29 /**
30 * @var \SimpleXMLElement
31 */
32 private $svnInfo;
33
34 /**
35 * @var SvnCommit
36 */
37 private $lastCommit;
38
39 /**
40 * Downloads the ICU data for the given version.
41 *
42 * @param string $url The URL to download from.
43 * @param string $targetDir The directory in which to store the repository.
44 *
45 * @return SvnRepository The directory where the data is stored.
46 *
47 * @throws RuntimeException If an error occurs during the download.
48 */
49 public static function download($url, $targetDir)
50 {
51 exec('which svn', $output, $result);
52
53 if ($result !== 0) {
54 throw new RuntimeException('The command "svn" is not installed.');
55 }
56
57 $filesystem = new Filesystem();
58
59 if (!$filesystem->exists($targetDir . '/.svn')) {
60 $filesystem->remove($targetDir);
61 $filesystem->mkdir($targetDir);
62
63 exec('svn checkout ' . $url . ' ' . $targetDir, $output, $result);
64
65 if ($result !== 0) {
66 throw new RuntimeException('The SVN checkout of ' . $url . 'failed.');
67 }
68 }
69
70 return new static(realpath($targetDir));
71 }
72
73 /**
74 * Reads the SVN repository at the given path.
75 *
76 * @param string $path The path to the repository.
77 */
78 public function __construct($path)
79 {
80 $this->path = $path;
81 }
82
83 /**
84 * Returns the path to the repository.
85 *
86 * @return string The path to the repository.
87 */
88 public function getPath()
89 {
90 return $this->path;
91 }
92
93 /**
94 * Returns the URL of the repository.
95 *
96 * @return string The URL of the repository.
97 */
98 public function getUrl()
99 {
100 return (string) $this->getSvnInfo()->entry->url;
101 }
102
103 /**
104 * Returns the last commit of the repository.
105 *
106 * @return SvnCommit The last commit.
107 */
108 public function getLastCommit()
109 {
110 if (null === $this->lastCommit) {
111 $this->lastCommit = new SvnCommit($this->getSvnInfo()->entry->commit);
112 }
113
114 return $this->lastCommit;
115 }
116
117 /**
118 * Returns information about the SVN repository.
119 *
120 * @return \SimpleXMLElement The XML result from the "svn info" command.
121 *
122 * @throws RuntimeException If the "svn info" command failed.
123 */
124 private function getSvnInfo()
125 {
126 if (null === $this->svnInfo) {
127 exec('svn info --xml '.$this->path, $output, $result);
128
129 $svnInfo = simplexml_load_string(implode("\n", $output));
130
131 if ($result !== 0) {
132 throw new RuntimeException('svn info failed');
133 }
134
135 $this->svnInfo = $svnInfo;
136 }
137
138 return $this->svnInfo;
139 }
140
141}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Util/Version.php b/vendor/symfony/intl/Symfony/Component/Intl/Util/Version.php
new file mode 100644
index 00000000..5f6a4337
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Util/Version.php
@@ -0,0 +1,96 @@
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\Util;
13
14/**
15 * Facilitates the comparison of version strings.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class Version
20{
21 /**
22 * Compares two versions with an operator.
23 *
24 * This method is identical to {@link version_compare()}, except that you
25 * can pass the number of regarded version components in the last argument
26 * $precision.
27 *
28 * Examples:
29 *
30 * Version::compare('1.2.3', '1.2.4', '==')
31 * // => false
32 *
33 * Version::compare('1.2.3', '1.2.4', '==', 2)
34 * // => true
35 *
36 * @param string $version1 A version string.
37 * @param string $version2 A version string to compare.
38 * @param string $operator The comparison operator.
39 * @param integer|null $precision The number of components to compare. Pass
40 * NULL to compare the versions unchanged.
41 *
42 * @return Boolean Whether the comparison succeeded.
43 *
44 * @see normalize()
45 */
46 public static function compare($version1, $version2, $operator, $precision = null)
47 {
48 $version1 = self::normalize($version1, $precision);
49 $version2 = self::normalize($version2, $precision);
50
51 return version_compare($version1, $version2, $operator);
52 }
53
54 /**
55 * Normalizes a version string to the number of components given in the
56 * parameter $precision.
57 *
58 * Examples:
59 *
60 * Version::normalize('1.2.3', 1);
61 * // => '1'
62 *
63 * Version::normalize('1.2.3', 2);
64 * // => '1.2'
65 *
66 * @param string $version A version string.
67 * @param integer|null $precision The number of components to include. Pass
68 * NULL to return the version unchanged.
69 *
70 * @return string|null The normalized version or NULL if it couldn't be
71 * normalized.
72 */
73 public static function normalize($version, $precision)
74 {
75 if (null === $precision) {
76 return $version;
77 }
78
79 $pattern = '[^\.]+';
80
81 for ($i = 2; $i <= $precision; ++$i) {
82 $pattern = sprintf('[^\.]+(\.%s)?', $pattern);
83 }
84
85 if (!preg_match('/^' . $pattern . '/', $version, $matches)) {
86 return null;
87 }
88
89 return $matches[0];
90 }
91
92 /**
93 * Must not be instantiated.
94 */
95 private function __construct() {}
96}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/composer.json b/vendor/symfony/intl/Symfony/Component/Intl/composer.json
new file mode 100644
index 00000000..29eedfa1
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/composer.json
@@ -0,0 +1,48 @@
1{
2 "name": "symfony/intl",
3 "type": "library",
4 "description": "A PHP replacement layer for the C intl extension that includes additional data from the ICU library.",
5 "keywords": ["intl", "icu", "internationalization", "localization", "i18n", "l10n"],
6 "homepage": "http://symfony.com",
7 "license": "MIT",
8 "authors": [
9 {
10 "name": "Bernhard Schussek",
11 "email": "bschussek@gmail.com"
12 },
13 {
14 "name": "Eriksen Costa",
15 "email": "eriksen.costa@infranology.com.br"
16 },
17 {
18 "name": "Igor Wiedler",
19 "email": "igor@wiedler.ch"
20 },
21 {
22 "name": "Symfony Community",
23 "homepage": "http://symfony.com/contributors"
24 }
25 ],
26 "require": {
27 "php": ">=5.3.3",
28 "symfony/icu": "~1.0-RC"
29 },
30 "require-dev": {
31 "symfony/filesystem": ">=2.1"
32 },
33 "suggest": {
34 "ext-intl": "to use the component with locales other than \"en\""
35 },
36 "autoload": {
37 "psr-0": { "Symfony\\Component\\Intl\\": "" },
38 "classmap": [ "Symfony/Component/Intl/Resources/stubs" ],
39 "files": [ "Symfony/Component/Intl/Resources/stubs/functions.php" ]
40 },
41 "target-dir": "Symfony/Component/Intl",
42 "minimum-stability": "dev",
43 "extra": {
44 "branch-alias": {
45 "dev-master": "2.3-dev"
46 }
47 }
48}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/phpunit.xml.dist b/vendor/symfony/intl/Symfony/Component/Intl/phpunit.xml.dist
new file mode 100644
index 00000000..5e709f13
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/phpunit.xml.dist
@@ -0,0 +1,29 @@
1<?xml version="1.0" encoding="UTF-8"?>
2
3<phpunit backupGlobals="false"
4 backupStaticAttributes="false"
5 colors="true"
6 convertErrorsToExceptions="true"
7 convertNoticesToExceptions="true"
8 convertWarningsToExceptions="true"
9 processIsolation="false"
10 stopOnFailure="false"
11 syntaxCheck="false"
12 bootstrap="vendor/autoload.php"
13>
14 <testsuites>
15 <testsuite name="Symfony Intl Component Test Suite">
16 <directory>./Tests/</directory>
17 </testsuite>
18 </testsuites>
19
20 <filter>
21 <whitelist>
22 <directory>./</directory>
23 <exclude>
24 <directory>./Tests</directory>
25 <directory>./vendor</directory>
26 </exclude>
27 </whitelist>
28 </filter>
29</phpunit>