Conditions | 3 |
Paths | 2 |
Total Lines | 83 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
37 | public function create( |
||
38 | AbstractProvider $theirProvider, |
||
39 | AbstractProvider $ourProvider, |
||
40 | AbstractProviderIdentity $identity, |
||
41 | string $relayState = null |
||
42 | ) { |
||
43 | |||
44 | $logout = new SamlLogoutRequest(); |
||
45 | |||
46 | /** |
||
47 | * Set remote destination |
||
48 | */ |
||
49 | $logout->setDestination( |
||
50 | $theirProvider->getType() === SettingsInterface::SP ? |
||
51 | $theirProvider->firstSpSloService()->getLocation() : |
||
52 | $theirProvider->firstIdpSloService()->getLocation() |
||
53 | ); |
||
54 | |||
55 | /** |
||
56 | * Set session id |
||
57 | */ |
||
58 | $logout->setSessionIndex($identity->sessionId); |
||
59 | |||
60 | $logout->setNotOnOrAfter( |
||
61 | (new \DateTime('+5 minutes'))->getTimestamp() |
||
62 | ); |
||
63 | $logout->setIssueInstant( |
||
64 | (new \DateTime())->getTimestamp() |
||
65 | ); |
||
66 | $logout->setConsent( |
||
67 | Constants::CONSENT_UNSPECIFIED |
||
68 | ); |
||
69 | |||
70 | $logout->setRelayState( |
||
71 | $relayState |
||
72 | ); |
||
73 | |||
74 | /** |
||
75 | * Set NameId |
||
76 | */ |
||
77 | $logout->setNameID( |
||
78 | $nameId = new NameID() |
||
79 | ); |
||
80 | |||
81 | $nameId->setValue($identity->nameId); |
||
|
|||
82 | $nameId->setFormat(Constants::NAMEID_EMAIL_ADDRESS); |
||
83 | |||
84 | /** |
||
85 | * Set issuer |
||
86 | */ |
||
87 | $logout->setIssuer( |
||
88 | $issuer = new Issuer() |
||
89 | ); |
||
90 | $issuer->setValue( |
||
91 | $ourProvider->getEntityId() |
||
92 | ); |
||
93 | |||
94 | /** |
||
95 | * Sign the message |
||
96 | */ |
||
97 | if ($ourProvider->keychain) { |
||
98 | $logout->setSignatureKey( |
||
99 | $ourProvider->keychainPrivateXmlSecurityKey() |
||
100 | ); |
||
101 | |||
102 | $logout->setCertificates([ |
||
103 | $ourProvider->keychain->certificate |
||
104 | ]); |
||
105 | } |
||
106 | |||
107 | /** |
||
108 | * Kick off event here so people can manipulate this object if needed |
||
109 | */ |
||
110 | $event = new Event(); |
||
111 | |||
112 | /** |
||
113 | * response |
||
114 | */ |
||
115 | $event->data = $logout; |
||
116 | $this->trigger(static::EVENT_AFTER_MESSAGE_CREATED, $event); |
||
117 | |||
118 | return $logout; |
||
119 | } |
||
120 | |||
137 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.