Conditions | 3 |
Paths | 2 |
Total Lines | 78 |
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 |
||
35 | public function create( |
||
36 | AbstractProvider $theirProvider, |
||
37 | AbstractProvider $ourProvider, |
||
38 | AbstractProviderIdentity $identity, |
||
39 | string $relayState = '' |
||
40 | ) |
||
41 | { |
||
42 | |||
43 | $logout = new SamlLogoutRequest(); |
||
44 | |||
45 | /** |
||
46 | * Set remote destination |
||
47 | */ |
||
48 | $logout->setDestination( |
||
49 | $theirProvider->getType() === SettingsInterface::SP ? |
||
50 | $theirProvider->firstSpSloService(Constants::BINDING_HTTP_POST)->getResponseLocation() : |
||
51 | $theirProvider->firstIdpSloService(Constants::BINDING_HTTP_POST)->getResponseLocation() |
||
52 | ); |
||
53 | |||
54 | /** |
||
55 | * Set session id |
||
56 | */ |
||
57 | $logout->setSessionIndex($identity->sessionId); |
||
58 | |||
59 | $logout->setNotOnOrAfter( |
||
60 | (new \DateTime('+5 minutes'))->getTimestamp() |
||
61 | ); |
||
62 | $logout->setIssueInstant( |
||
63 | (new \DateTime())->getTimestamp() |
||
64 | ); |
||
65 | $logout->setConsent( |
||
66 | Constants::CONSENT_UNSPECIFIED |
||
67 | ); |
||
68 | |||
69 | $logout->setRelayState( |
||
70 | $relayState |
||
71 | ); |
||
72 | |||
73 | /** |
||
74 | * Set NameId |
||
75 | */ |
||
76 | $logout->setNameID( |
||
77 | $nameId = new NameID() |
||
78 | ); |
||
79 | |||
80 | $nameId->setValue($identity->nameId); |
||
|
|||
81 | $nameId->setFormat(Constants::NAMEID_EMAIL_ADDRESS); |
||
82 | |||
83 | /** |
||
84 | * Set issuer |
||
85 | */ |
||
86 | $logout->setIssuer( |
||
87 | $ourProvider->getEntityId() |
||
88 | ); |
||
89 | |||
90 | /** |
||
91 | * Sign the message |
||
92 | */ |
||
93 | if ($ourProvider->keychain) { |
||
94 | $logout->setSignatureKey( |
||
95 | $ourProvider->keychainPrivateXmlSecurityKey() |
||
96 | ); |
||
97 | } |
||
98 | |||
99 | |||
100 | /** |
||
101 | * Kick off event here so people can manipulate this object if needed |
||
102 | */ |
||
103 | $event = new Event(); |
||
104 | |||
105 | /** |
||
106 | * response |
||
107 | */ |
||
108 | $event->data = $logout; |
||
109 | $this->trigger(static::EVENT_AFTER_MESSAGE_CREATED, $event); |
||
110 | |||
111 | return $logout; |
||
112 | } |
||
113 | } |
||
114 |
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.