Completed
Push — master ( 2a17e7...e610ee )
by Arne
04:45
created

AbstractPhpHashAlgorithm   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 28
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A initialize() 0 4 1
A digest() 0 4 1
A finalize() 0 4 1
1
<?php
2
3
namespace Storeman\Hash\Algorithm;
4
5
abstract class AbstractPhpHashAlgorithm implements HashAlgorithmInterface
6
{
7
    protected $context;
8
9
    /**
10
     * {@inheritdoc}
11
     */
12
    public function initialize(): void
13
    {
14
        $this->context = hash_init($this->getName());
15
    }
16
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function digest(string $buffer): void
21
    {
22
        hash_update($this->context, $buffer);
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function finalize(): string
29
    {
30
        return hash_final($this->context);
31
    }
32
}
33