StandardHashingStrategy   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 18
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A hash() 0 12 4
1
<?php
2
3
/*
4
 * This file is part of Transfer.
5
 *
6
 * For the full copyright and license information, please view the LICENSE file located
7
 * in the root directory.
8
 */
9
10
namespace Transfer\Storage\Hashing;
11
12
/**
13
 * Standard hashing strategy.
14
 */
15
class StandardHashingStrategy implements HashingStrategyInterface
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20 11
    public function hash($object)
21
    {
22 11
        if (is_object($object)) {
23 1
            return spl_object_hash($object);
24 10
        } elseif (is_string($object)) {
25 9
            return md5($object);
26 3
        } elseif (is_array($object)) {
27 2
            return md5(serialize($object));
28
        }
29
30 1
        throw new \InvalidArgumentException(sprintf('Object of type "%s" can not be hashed.', gettype($object)));
31
    }
32
}
33