Code Duplication    Length = 26-26 lines in 3 locations

src/PhpSpreadsheet/Calculation/DateTime.php 3 locations

@@ 1344-1369 (lines=26) @@
1341
     *                                    PHP DateTime object, or a standard time string
1342
     * @return    int        Hour
1343
     */
1344
    public static function HOUROFDAY($timeValue = 0)
1345
    {
1346
        $timeValue = Functions::flattenSingleValue($timeValue);
1347
1348
        if (!is_numeric($timeValue)) {
1349
            if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
1350
                $testVal = strtok($timeValue, '/-: ');
1351
                if (strlen($testVal) < strlen($timeValue)) {
1352
                    return Functions::VALUE();
1353
                }
1354
            }
1355
            $timeValue = self::getTimeValue($timeValue);
1356
            if (is_string($timeValue)) {
1357
                return Functions::VALUE();
1358
            }
1359
        }
1360
        // Execute function
1361
        if ($timeValue >= 1) {
1362
            $timeValue = fmod($timeValue, 1);
1363
        } elseif ($timeValue < 0.0) {
1364
            return Functions::NAN();
1365
        }
1366
        $timeValue = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($timeValue);
1367
1368
        return (int) gmdate('G', $timeValue);
1369
    }
1370
1371
    /**
1372
     * MINUTE
@@ 1384-1409 (lines=26) @@
1381
     *                                    PHP DateTime object, or a standard time string
1382
     * @return    int        Minute
1383
     */
1384
    public static function MINUTE($timeValue = 0)
1385
    {
1386
        $timeValue = $timeTester = Functions::flattenSingleValue($timeValue);
1387
1388
        if (!is_numeric($timeValue)) {
1389
            if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
1390
                $testVal = strtok($timeValue, '/-: ');
1391
                if (strlen($testVal) < strlen($timeValue)) {
1392
                    return Functions::VALUE();
1393
                }
1394
            }
1395
            $timeValue = self::getTimeValue($timeValue);
1396
            if (is_string($timeValue)) {
1397
                return Functions::VALUE();
1398
            }
1399
        }
1400
        // Execute function
1401
        if ($timeValue >= 1) {
1402
            $timeValue = fmod($timeValue, 1);
1403
        } elseif ($timeValue < 0.0) {
1404
            return Functions::NAN();
1405
        }
1406
        $timeValue = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($timeValue);
1407
1408
        return (int) gmdate('i', $timeValue);
1409
    }
1410
1411
    /**
1412
     * SECOND
@@ 1424-1449 (lines=26) @@
1421
     *                                    PHP DateTime object, or a standard time string
1422
     * @return    int        Second
1423
     */
1424
    public static function SECOND($timeValue = 0)
1425
    {
1426
        $timeValue = Functions::flattenSingleValue($timeValue);
1427
1428
        if (!is_numeric($timeValue)) {
1429
            if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
1430
                $testVal = strtok($timeValue, '/-: ');
1431
                if (strlen($testVal) < strlen($timeValue)) {
1432
                    return Functions::VALUE();
1433
                }
1434
            }
1435
            $timeValue = self::getTimeValue($timeValue);
1436
            if (is_string($timeValue)) {
1437
                return Functions::VALUE();
1438
            }
1439
        }
1440
        // Execute function
1441
        if ($timeValue >= 1) {
1442
            $timeValue = fmod($timeValue, 1);
1443
        } elseif ($timeValue < 0.0) {
1444
            return Functions::NAN();
1445
        }
1446
        $timeValue = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($timeValue);
1447
1448
        return (int) gmdate('s', $timeValue);
1449
    }
1450
1451
    /**
1452
     * EDATE