HNSHK::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 31

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 31
ccs 19
cts 19
cp 1
rs 9.424
c 0
b 0
f 0
cc 1
nc 1
nop 10
crap 1

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
namespace Fhp\Segment;
4
5
use Fhp\DataElementGroups\HashAlgorithm;
6
use Fhp\DataElementGroups\KeyName;
7
use Fhp\DataElementGroups\SecurityDateTime;
8
use Fhp\DataElementGroups\SecurityIdentificationDetails;
9
use Fhp\DataElementGroups\SecurityProfile;
10
use Fhp\DataElementGroups\SignatureAlgorithm;
11
12
/**
13
 * Class HNSHK (Signaturkopf)
14
 * Segment type: Administration
15
 *
16
 * @link: http://www.hbci-zka.de/dokumente/spezifikation_deutsch/fintsv3/FinTS_3.0_Security_Sicherheitsverfahren_HBCI_Rel_20130718_final_version.pdf
17
 * Section: B.5.1
18
 *
19
 * @package Fhp\Segment
20
 */
21
class HNSHK extends AbstractSegment
22
{
23
    const NAME = 'HNSHK';
24
    const VERSION = 4;
25
26
    const SECURITY_FUNC_NRO = 1; // Non-Repudiation of Origin, für RAH, RDH (NRO)
27
    const SECURITY_FUNC_AUT = 2; // Message Origin Authentication, für RAH, RDH und DDV (AUT)
28
    const SECURITY_FUNC_ENC = 4; // Encryption, Verschlüsselung und evtl. Komprimierung (ENC)
29
    const SECURITY_FUNC_999 = 999;
30
31
    const SECURITY_BOUNDARY_SHM = 1; // Signaturkopf und HBCI-Nutzdaten (SHM)
32
    const SECURITY_BOUNDARY_SHT = 2; // Von Signaturkopf bis Signaturabschluss (SHT)
33
34
    const SECURITY_SUPPLIER_ROLE_ISS = 1; // Der Unterzeichner ist Herausgeber der signierten Nachricht, z.B. Erfasser oder Erstsignatur (ISS)
35
    const SECURITY_SUPPLIER_ROLE_CON = 3; // Der Unterzeichner unterstützt den Inhalt der Nachricht, z.B. bei Zweitsignatur (CON)
36
    const SECURITY_SUPPLIER_ROLE_WIT = 4; // Der Unterzeichner ist Zeuge, aber für den Inhalt der Nachricht nicht verantwortlich, z.B. Übermittler, welcher nicht Erfasser ist (WIT)
37
38
    /**
39
     * HNSHK constructor.
40
     * @param int $segmentNumber
41
     * @param string $securityReference
42
     * @param string $countryCode
43
     * @param string $bankCode
44
     * @param string $userName
45
     * @param int $systemId
46
     * @param int $securityFunction
47
     * @param int $securityBoundary
48
     * @param int $securitySupplierRole
49
     * @param int $pinTanVersion
50
     */
51 4
    public function __construct(
52
        $segmentNumber,
53
        $securityReference,
54
        $countryCode,
55
        $bankCode,
56
        $userName,
57
        $systemId = 0,
58
        $securityFunction = self::SECURITY_FUNC_999,
59
        $securityBoundary = self::SECURITY_BOUNDARY_SHM,
60
        $securitySupplierRole = self::SECURITY_SUPPLIER_ROLE_ISS,
61
        $pinTanVersion = SecurityProfile::PROFILE_VERSION_1
62
    ) {
63 4
        parent::__construct(
64 4
            static::NAME,
65 4
            $segmentNumber,
66 4
            static::VERSION,
67
            array(
68 4
                new SecurityProfile(SecurityProfile::PROFILE_PIN, $pinTanVersion), #2
69 4
                $securityFunction, #3
70 4
                $securityReference, #4
71 4
                $securityBoundary, #5
72 4
                $securitySupplierRole, #6
73 4
                new SecurityIdentificationDetails(SecurityIdentificationDetails::CID_NONE, $systemId), #7
74 4
                1, #8
75 4
                new SecurityDateTime(), #9
76 4
                new HashAlgorithm(), #10
77 4
                new SignatureAlgorithm(), #11
78 4
                new KeyName($countryCode, $bankCode, $userName, KeyName::KEY_TYPE_SIGNATURE)                #12
79 4
            )
80 4
        );
81 4
    }
82
83
    /**
84
     * @return string
85
     */
86
    public function getName()
87
    {
88
        return static::NAME;
89
    }
90
}
91