Completed
Push — 2.0 ( 0357a9...3fe951 )
by Peter
08:22 queued 10s
created

CurrentTimeExecutorSpec::getMatchers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * This file is part of the Happyr Doctrine Specification package.
6
 *
7
 * (c) Tobias Nyholm <[email protected]>
8
 *     Kacper Gunia <[email protected]>
9
 *     Peter Gribanov <[email protected]>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
namespace tests\Happyr\DoctrineSpecification\Operand\PlatformFunction\Executor;
16
17
use Happyr\DoctrineSpecification\Operand\PlatformFunction\Executor\CurrentTimeExecutor;
18
use PhpSpec\ObjectBehavior;
19
20
/**
21
 * @mixin CurrentTimeExecutor
22
 */
23 View Code Duplication
final class CurrentTimeExecutorSpec extends ObjectBehavior
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
{
25
    public function it_should_return_current_time(): void
26
    {
27
        $this()->shouldBeAnInstanceOf(\DateTimeImmutable::class);
28
        $this()->shouldBeWithDefaultTimeZone();
29
        $this()->shouldBeCurrentTime();
30
    }
31
32
    public function getMatchers(): array
33
    {
34
        return [
35
            'beWithDefaultTimeZone' => function (\DateTimeInterface $subject): bool {
36
                return $subject->getTimezone()->getName() === date_default_timezone_get();
37
            },
38
            'beCurrentTime' => function (\DateTimeInterface $subject): bool {
39
                return $subject->getTimestamp() === (new \DateTimeImmutable())->setDate(1, 1, 1)->getTimestamp();
40
            },
41
        ];
42
    }
43
}
44