EventIdSpec   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 33
rs 10
c 1
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A it_has_an_identifier() 0 3 1
A it_throws_an_exception_when_identifier_is_not_a_valid_uuid() 0 5 1
A it_generate_an_uuid_internally() 0 5 1
A let() 0 4 1
A it_is_initializable() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of slick/event package
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace spec\Slick\Event\Domain;
11
12
use Ramsey\Uuid\Uuid;
13
use Slick\Event\Domain\EventId;
14
use PhpSpec\ObjectBehavior;
15
16
/**
17
 * EventIdSpec specs
18
 *
19
 * @package spec\Slick\Event\Event
20
 */
21
class EventIdSpec extends ObjectBehavior
22
{
23
24
    private $identifier;
25
26
    function let()
27
    {
28
        $this->identifier = (string)Uuid::uuid4();
29
        $this->beConstructedWith($this->identifier);
30
    }
31
32
    function it_is_initializable()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
33
    {
34
        $this->shouldHaveType(EventId::class);
35
    }
36
37
    function it_has_an_identifier()
38
    {
39
        $this->__toString()->shouldBe($this->identifier);
0 ignored issues
show
Bug introduced by
The method __toString() does not exist on spec\Slick\Event\Domain\EventIdSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

39
        $this->/** @scrutinizer ignore-call */ 
40
               __toString()->shouldBe($this->identifier);
Loading history...
40
    }
41
42
    function it_throws_an_exception_when_identifier_is_not_a_valid_uuid()
43
    {
44
        $this->beConstructedWith('test');
45
        $this->shouldThrow(\InvalidArgumentException::class)
46
            ->duringInstantiation();
47
    }
48
49
    function it_generate_an_uuid_internally()
50
    {
51
        $regEx = '/\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b/i';
52
        $this->beConstructedWith(null);
53
        $this->__toString()->shouldMatch($regEx);
54
    }
55
}
56