Code Duplication    Length = 12-12 lines in 2 locations

src/date/DateFormat.class.php 2 locations

@@ 228-239 (lines=12) @@
225
     */
226
    public function format($data, $calendarType = Calendar::GREGORIAN, $locale = null)
227
    {
228
        if ($locale instanceof Locale) {
229
            $tm = $locale->getContext()->getTranslationManager();
230
        } elseif ($this->context) {
231
            $tm = $this->context->getTranslationManager();
232
            if ($locale) {
233
                $locale = $tm->getLocale($locale);
234
            } else {
235
                $locale = $tm->getCurrentLocale();
236
            }
237
        } else {
238
            throw new \InvalidArgumentException('This AgaviDateFormat has not been initialize()d. To be able to pass a string as locale you need to call initialize() or create this DateFormat using TranslationManager::createDateFormat()');
239
        }
240
        
241
        $tzid = null;
242
        if ($locale->getLocaleTimeZone()) {
@@ 638-649 (lines=12) @@
635
     */
636
    public function parse($dateString, $locale = null, $strict = false)
637
    {
638
        if ($locale instanceof Locale) {
639
            $tm = $locale->getContext()->getTranslationManager();
640
        } elseif ($this->context) {
641
            $tm = $this->context->getTranslationManager();
642
            if ($locale) {
643
                $locale = $tm->getLocale($locale);
644
            } else {
645
                $locale = $tm->getCurrentLocale();
646
            }
647
        } else {
648
            throw new \InvalidArgumentException('This DateFormat has not been initialize()d. To be able to pass a string as locale you need to call initialize() or create this DateFormat using TranslationManager::createDateFormat()');
649
        }
650
        
651
        $cal = $tm->createCalendar($locale);
652
        // we need to extract the era from the current date and set that