ContactsCollectionHashable::resolveIndexOf()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 1
crap 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