Code Duplication    Length = 26-26 lines in 3 locations

src/PhpSpreadsheet/Calculation/DateTime.php 3 locations

@@ 1357-1382 (lines=26) @@
1354
     *                                    PHP DateTime object, or a standard time string
1355
     * @return    int        Hour
1356
     */
1357
    public static function HOUROFDAY($timeValue = 0)
1358
    {
1359
        $timeValue    = Functions::flattenSingleValue($timeValue);
1360
1361
        if (!is_numeric($timeValue)) {
1362
            if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
1363
                $testVal = strtok($timeValue, '/-: ');
1364
                if (strlen($testVal) < strlen($timeValue)) {
1365
                    return Functions::VALUE();
1366
                }
1367
            }
1368
            $timeValue = self::getTimeValue($timeValue);
1369
            if (is_string($timeValue)) {
1370
                return Functions::VALUE();
1371
            }
1372
        }
1373
        // Execute function
1374
        if ($timeValue >= 1) {
1375
            $timeValue = fmod($timeValue, 1);
1376
        } elseif ($timeValue < 0.0) {
1377
            return Functions::NAN();
1378
        }
1379
        $timeValue = \PhpSpreadsheet\Shared\Date::excelToTimestamp($timeValue);
1380
1381
        return (int) gmdate('G', $timeValue);
1382
    }
1383
1384
1385
    /**
@@ 1398-1423 (lines=26) @@
1395
     *                                    PHP DateTime object, or a standard time string
1396
     * @return    int        Minute
1397
     */
1398
    public static function MINUTEOFHOUR($timeValue = 0)
1399
    {
1400
        $timeValue = $timeTester    = Functions::flattenSingleValue($timeValue);
1401
1402
        if (!is_numeric($timeValue)) {
1403
            if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
1404
                $testVal = strtok($timeValue, '/-: ');
1405
                if (strlen($testVal) < strlen($timeValue)) {
1406
                    return Functions::VALUE();
1407
                }
1408
            }
1409
            $timeValue = self::getTimeValue($timeValue);
1410
            if (is_string($timeValue)) {
1411
                return Functions::VALUE();
1412
            }
1413
        }
1414
        // Execute function
1415
        if ($timeValue >= 1) {
1416
            $timeValue = fmod($timeValue, 1);
1417
        } elseif ($timeValue < 0.0) {
1418
            return Functions::NAN();
1419
        }
1420
        $timeValue = \PhpSpreadsheet\Shared\Date::excelToTimestamp($timeValue);
1421
1422
        return (int) gmdate('i', $timeValue);
1423
    }
1424
1425
1426
    /**
@@ 1439-1464 (lines=26) @@
1436
     *                                    PHP DateTime object, or a standard time string
1437
     * @return    int        Second
1438
     */
1439
    public static function SECONDOFMINUTE($timeValue = 0)
1440
    {
1441
        $timeValue    = Functions::flattenSingleValue($timeValue);
1442
1443
        if (!is_numeric($timeValue)) {
1444
            if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
1445
                $testVal = strtok($timeValue, '/-: ');
1446
                if (strlen($testVal) < strlen($timeValue)) {
1447
                    return Functions::VALUE();
1448
                }
1449
            }
1450
            $timeValue = self::getTimeValue($timeValue);
1451
            if (is_string($timeValue)) {
1452
                return Functions::VALUE();
1453
            }
1454
        }
1455
        // Execute function
1456
        if ($timeValue >= 1) {
1457
            $timeValue = fmod($timeValue, 1);
1458
        } elseif ($timeValue < 0.0) {
1459
            return Functions::NAN();
1460
        }
1461
        $timeValue = \PhpSpreadsheet\Shared\Date::excelToTimestamp($timeValue);
1462
1463
        return (int) gmdate('s', $timeValue);
1464
    }
1465
1466
1467
    /**