Conditions | 10 |
Paths | 29 |
Total Lines | 46 |
Code Lines | 30 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
50 | protected function doExecute(ProfileContext $context) |
||
51 | { |
||
52 | $partyContext = $context->getPartyEntityContext(); |
||
53 | |||
54 | if ($partyContext->getEntityDescriptor() && $partyContext->getTrustOptions()) { |
||
55 | $this->logger->debug( |
||
56 | sprintf('Party EntityDescriptor and TrustOptions already set for "%s"', $partyContext->getEntityDescriptor()->getEntityID()), |
||
57 | LogHelper::getActionContext($context, $this, [ |
||
58 | 'partyEntityId' => $partyContext->getEntityDescriptor()->getEntityID(), |
||
59 | ]) |
||
60 | ); |
||
61 | |||
62 | return; |
||
63 | } |
||
64 | |||
65 | $entityId = $partyContext->getEntityDescriptor() ? $partyContext->getEntityDescriptor()->getEntityID() : null; |
||
66 | $entityId = $entityId ? $entityId : $partyContext->getEntityId(); |
||
67 | if (null == $entityId) { |
||
68 | $message = 'EntityID is not set in the party context'; |
||
69 | $this->logger->critical($message, LogHelper::getActionErrorContext($context, $this)); |
||
70 | throw new LightSamlContextException($context, $message); |
||
71 | } |
||
72 | |||
73 | if (null == $partyContext->getEntityDescriptor()) { |
||
74 | $partyEntityDescriptor = $this->getPartyEntityDescriptor( |
||
75 | $context, |
||
76 | ProfileContext::ROLE_IDP === $context->getOwnRole() |
||
77 | ? $this->spEntityDescriptorProvider |
||
78 | : $this->idpEntityDescriptorProvider, |
||
79 | $context->getPartyEntityContext()->getEntityId() |
||
80 | ); |
||
81 | $partyContext->setEntityDescriptor($partyEntityDescriptor); |
||
82 | $this->logger->debug( |
||
83 | sprintf('Known issuer resolved: "%s"', $partyEntityDescriptor->getEntityID()), |
||
84 | LogHelper::getActionContext($context, $this, [ |
||
85 | 'partyEntityId' => $partyEntityDescriptor->getEntityID(), |
||
86 | ]) |
||
87 | ); |
||
88 | } |
||
89 | |||
90 | if (null == $partyContext->getTrustOptions()) { |
||
91 | $trustOptions = $this->trustOptionsProvider->get($partyContext->getEntityDescriptor()->getEntityID()); |
||
92 | if (null === $trustOptions) { |
||
93 | $trustOptions = new TrustOptions(); |
||
94 | } |
||
95 | $partyContext->setTrustOptions($trustOptions); |
||
96 | } |
||
119 |