Code Duplication    Length = 15-15 lines in 2 locations

core/services/helpers/datetime/PhpCompatLessFiveSixHelper.php 1 location

@@ 94-108 (lines=15) @@
91
        $gmt_offset = (int) $gmt_offset;
92
        /** @var array[] $abbreviations */
93
        $abbreviations = DateTimeZone::listAbbreviations();
94
        foreach ($abbreviations as $abbreviation) {
95
            foreach ($abbreviation as $timezone) {
96
                if ((int) $timezone['offset'] === $gmt_offset && (bool) $timezone['dst'] === false) {
97
                    try {
98
                        $offset = $this->getTimezoneOffset(new DateTimeZone($timezone['timezone_id']));
99
                        if ($offset !== $gmt_offset) {
100
                            continue;
101
                        }
102
                        return $timezone['timezone_id'];
103
                    } catch (Exception $e) {
104
                        continue;
105
                    }
106
                }
107
            }
108
        }
109
        // if $coerce is true, let's see if we can get a timezone string after the offset is adjusted
110
        if ($coerce === true) {
111
            $timezone_string = $this->getTimezoneStringFromAbbreviationsList(

core/helpers/EEH_DTT_Helper.helper.php 1 location

@@ 137-151 (lines=15) @@
134
        $gmt_offset =  (int) $gmt_offset;
135
        /** @var array[] $abbreviations */
136
        $abbreviations = DateTimeZone::listAbbreviations();
137
        foreach ($abbreviations as $abbreviation) {
138
            foreach ($abbreviation as $timezone) {
139
                if ((int) $timezone['offset'] === $gmt_offset && (bool) $timezone['dst'] === false) {
140
                    try {
141
                        $offset = self::get_timezone_offset(new DateTimeZone($timezone['timezone_id']));
142
                        if ($offset !== $gmt_offset) {
143
                            continue;
144
                        }
145
                        return $timezone['timezone_id'];
146
                    } catch (Exception $e) {
147
                        continue;
148
                    }
149
                }
150
            }
151
        }
152
        // if $coerce is true, let's see if we can get a timezone string after the offset is adjusted
153
        if ($coerce === true) {
154
            $timezone_string = self::get_timezone_string_from_abbreviations_list(