Code Duplication    Length = 40-40 lines in 2 locations

src/date/SimpleTimeZone.class.php 2 locations

@@ 1333-1372 (lines=40) @@
1330
     * @author     The ICU Project
1331
     * @since      0.11.0
1332
     */
1333
    private function decodeStartRule()
1334
    {
1335
        $this->useDaylight = (($this->startDay != 0) && ($this->endDay != 0) ? true : false);
1336
        if ($this->useDaylight && $this->dstSavings == 0) {
1337
            $this->dstSavings = DateDefinitions::MILLIS_PER_HOUR;
1338
        }
1339
        if ($this->startDay != 0) {
1340
            if ($this->startMonth < DateDefinitions::JANUARY || $this->startMonth > DateDefinitions::DECEMBER) {
1341
                throw new \InvalidArgumentException('startMonth out of range');
1342
            }
1343
            if ($this->startTime < 0 || $this->startTime > DateDefinitions::MILLIS_PER_DAY || $this->startTimeMode < self::WALL_TIME || $this->startTimeMode > self::UTC_TIME) {
1344
                throw new \InvalidArgumentException('startTime out of range');
1345
            }
1346
            if ($this->startDayOfWeek == 0) {
1347
                $this->startMode = self::DOM_MODE;
1348
            } else {
1349
                if ($this->startDayOfWeek > 0) {
1350
                    $this->startMode = self::DOW_IN_MONTH_MODE;
1351
                } else {
1352
                    $this->startDayOfWeek = -$this->startDayOfWeek;
1353
                    if ($this->startDay > 0) {
1354
                        $this->startMode = self::DOW_GE_DOM_MODE;
1355
                    } else {
1356
                        $this->startDay = -$this->startDay;
1357
                        $this->startMode = self::DOW_LE_DOM_MODE;
1358
                    }
1359
                }
1360
                if ($this->startDayOfWeek > DateDefinitions::SATURDAY) {
1361
                    throw new \InvalidArgumentException('startDayOfWeek out of range');
1362
                }
1363
            }
1364
            if ($this->startMode == self::DOW_IN_MONTH_MODE) {
1365
                if ($this->startDay < -5 || $this->startDay > 5) {
1366
                    throw new \InvalidArgumentException('startDay out of range');
1367
                }
1368
            } elseif ($this->startDay < 1 || $this->startDay > self::$STATICMONTHLENGTH[$this->startMonth]) {
1369
                throw new \InvalidArgumentException('startDay out of range');
1370
            }
1371
        }
1372
    }
1373
1374
    /**
1375
     * Decode the end rule and validate the parameters.  This method is exactly
@@ 1384-1423 (lines=40) @@
1381
     * @author     The ICU Project
1382
     * @since      0.11.0
1383
     */
1384
    private function decodeEndRule()
1385
    {
1386
        $this->useDaylight = (($this->startDay != 0) && ($this->endDay != 0) ? true : false);
1387
        if ($this->useDaylight && $this->dstSavings == 0) {
1388
            $this->dstSavings = DateDefinitions::MILLIS_PER_HOUR;
1389
        }
1390
        if ($this->endDay != 0) {
1391
            if ($this->endMonth < DateDefinitions::JANUARY || $this->endMonth > DateDefinitions::DECEMBER) {
1392
                throw new \InvalidArgumentException('endMonth out of range');
1393
            }
1394
            if ($this->endTime < 0 || $this->endTime > DateDefinitions::MILLIS_PER_DAY || $this->endTimeMode < self::WALL_TIME || $this->endTimeMode > self::UTC_TIME) {
1395
                throw new \InvalidArgumentException('endTime out of range');
1396
            }
1397
            if ($this->endDayOfWeek == 0) {
1398
                $this->endMode = self::DOM_MODE;
1399
            } else {
1400
                if ($this->endDayOfWeek > 0) {
1401
                    $this->endMode = self::DOW_IN_MONTH_MODE;
1402
                } else {
1403
                    $this->endDayOfWeek = -$this->endDayOfWeek;
1404
                    if ($this->endDay > 0) {
1405
                        $this->endMode = self::DOW_GE_DOM_MODE;
1406
                    } else {
1407
                        $this->endDay = -$this->endDay;
1408
                        $this->endMode = self::DOW_LE_DOM_MODE;
1409
                    }
1410
                }
1411
                if ($this->endDayOfWeek > DateDefinitions::SATURDAY) {
1412
                    throw new \InvalidArgumentException('endDayOfWeek out of range');
1413
                }
1414
            }
1415
            if ($this->endMode == self::DOW_IN_MONTH_MODE) {
1416
                if ($this->endDay < -5 || $this->endDay > 5) {
1417
                    throw new \InvalidArgumentException('endDay out of range');
1418
                }
1419
            } elseif ($this->endDay < 1 || $this->endDay > self::$STATICMONTHLENGTH[$this->endMonth]) {
1420
                throw new \InvalidArgumentException('endDay out of range');
1421
            }
1422
        }
1423
    }
1424
1425
    private $startMonth, $startDay, $startDayOfWeek;   // the month, day, DOW, and time DST starts
1426
    private $startTime;