Passed
Push — master ( da3c73...a3b48d )
by Evgenii
02:05
created

ContactsCollectionHashable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 4
dl 0
loc 21
ccs 4
cts 6
cp 0.6667
rs 10
c 2
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getItemClass() 0 3 1
A resolveIndexOf() 0 3 1
A getItemName() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of the ddd-common.
5
 *
6
 * Copyright 2021 Evgenii Dudal <[email protected]>.
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 * @package ddd-common
11
 */
12
13
namespace RobotE13\DDD\Entities\Collection\Contact;
14
15
use RobotE13\DDD\Entities\Collection\Contact\Contact;
16
use RobotE13\DDD\Entities\Collection\AbstractHashableCollection;
17
18
/**
19
 * Description of HashableContactsCollection
20
 *
21
 * @author Evgenii Dudal <[email protected]>
22
 */
23
class ContactsCollectionHashable extends AbstractHashableCollection
24
{
25
26
    public function getItemClass(): string
27
    {
28
        return Contact::class;
29
    }
30
31 2
    public static function getItemName(): string
32
    {
33 2
        return 'Contact';
34
    }
35
36
    /**
37
     *
38
     * @param Contact $item
39
     * @return string
40
     */
41 2
    public function resolveIndexOf($item): string
42
    {
43 2
        return hash('crc32', "{$item->getType()}_{$item->getValue()}");
44
    }
45
46
}
47