Passed
Push — master ( fe8da9...4bb742 )
by Saulius
02:35
created

countdown_calculate_days_in_hours()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 7
ccs 3
cts 3
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 18 and the first side effect is on line 18.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * This file is part of the sauls/helpers package.
4
 *
5
 * @author    Saulius Vaičeliūnas <[email protected]>
6
 * @link      http://saulius.vaiceliunas.lt
7
 * @copyright 2018
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Sauls\Component\Helper;
14
15
use Sauls\Component\Helper\Operation\Factory\OperationFactory;
16
use Sauls\Component\Helper\Operation\DateTimeOperation;
17
18
\define('ELAPSED_TIME_FORMAT_FULL', DateTimeOperation\ElapsedTime::ELAPSED_TIME_FORMAT_FULL);
19
\define('ELAPSED_TIME_FORMAT_SHORT', DateTimeOperation\ElapsedTime::ELAPSED_TIME_FORMAT_SHORT);
20
21
/**
22
 * @throws \Exception
23
 */
24
function elapsed_time($date, array $labels = [], $format = ELAPSED_TIME_FORMAT_FULL): string
25
{
26 14
    return OperationFactory::create(DateTimeOperation\ElapsedTime::class)
27 14
        ->execute($date, $labels, $format);
0 ignored issues
show
Bug introduced by
The method execute() does not exist on Sauls\Component\Helper\Operation\Operation. Since it exists in all sub-types, consider adding an abstract or default implementation to Sauls\Component\Helper\Operation\Operation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
        ->/** @scrutinizer ignore-call */ execute($date, $labels, $format);
Loading history...
28
}
29
30
/**
31
 * @param string|\DateTime $dateFrom
32
 * @param string|\DateTime $dateTo
33
 */
34
function countdown($dateFrom = 'now', $dateTo, string $format = '%s%02d:%02d:%02d'): string
35
{
36 7
    return OperationFactory::create(DateTimeOperation\Countdown::class)->execute($dateFrom, $dateTo, $format);
37
}
38