Completed
Push — middleware-wip-tmp ( d8f2e1 )
by Romain
02:50
created

FormObjectHash::getHash()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 8
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
/*
3
 * 2017 Romain CANON <[email protected]>
4
 *
5
 * This file is part of the TYPO3 FormZ project.
6
 * It is free software; you can redistribute it and/or modify it
7
 * under the terms of the GNU General Public License, either
8
 * version 3 of the License, or any later version.
9
 *
10
 * For the full copyright and license information, see:
11
 * http://www.gnu.org/licenses/gpl-3.0.html
12
 */
13
14
namespace Romm\Formz\Form\Service;
15
16
use Romm\Formz\Form\FormObject\FormObject;
17
use Romm\Formz\Service\HashService;
18
19
class FormObjectHash
20
{
21
    /**
22
     * @var FormObject
23
     */
24
    protected $formObject;
25
26
    /**
27
     * @var string
28
     */
29
    protected $formHash;
30
31
    /**
32
     * @param FormObject $formObject
33
     */
34
    public function __construct(FormObject $formObject)
35
    {
36
        $this->formObject = $formObject;
37
    }
38
39
    /**
40
     * @param string $hash
41
     */
42
    public function setFormHash($hash)
43
    {
44
        $this->formHash = $hash;
45
    }
46
47
    /**
48
     * @return string
49
     */
50
    public function getFormHash()
51
    {
52
        if (null === $this->formHash) {
53
            $this->formHash = HashService::get()->getHash(uniqid($this->formObject->getClassName()));
54
        }
55
56
        return $this->formHash;
57
    }
58
}
59