StreamHasher   A
last analyzed

Coupling/Cohesion

Components 1
Dependencies 0

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 32
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A hash() 0 9 1
1
<?php
2
3
namespace League\Flysystem\Util;
4
5
class StreamHasher
6
{
7
    /**
8
     * @var string
9
     */
10
    private $algo;
11
12
    /**
13
     * StreamHasher constructor.
14
     *
15
     * @param string $algo
16
     */
17 3
    public function __construct($algo)
18
    {
19 3
        $this->algo = $algo;
20 3
    }
21
22
    /**
23
     * @param $resource
24
     *
25
     * @return string
26
     */
27 3
    public function hash($resource)
28
    {
29 3
        rewind($resource);
30 3
        $context = hash_init($this->algo);
31 3
        hash_update_stream($context, $resource);
32 3
        fclose($resource);
33
34 3
        return hash_final($context);
35
    }
36
}
37