Conditions | 6 |
Paths | 4 |
Total Lines | 57 |
Code Lines | 35 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
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 |
||
82 | public function createProfile($identityId) |
||
83 | { |
||
84 | $identity = $this->identityService->find($identityId); |
||
85 | |||
86 | if ($identity === null) { |
||
87 | $this->logger->notice(sprintf('No Identity found with IdentityId %s', $identityId)); |
||
88 | return null; |
||
89 | } |
||
90 | $this->logger->notice(sprintf('Found IdentityId "%s" NameId "%s"', $identityId, $identity->nameId )); |
||
91 | |||
92 | $raListing = $this->raListingRepository->findByIdentityId(new IdentityId($identityId)); |
||
93 | $isRa = $this->getRoleFromListing($raListing, AuthorityRole::ROLE_RA); |
||
94 | $isRaa = $this->getRoleFromListing($raListing, AuthorityRole::ROLE_RAA); |
||
95 | |||
96 | $this->logger->notice( |
||
97 | sprintf( |
||
98 | 'Based on RaListing Identity %s has roles(RA: %s, RAA: %s)', |
||
99 | $identityId, |
||
100 | $isRa ? "YES" : "NO", |
||
101 | $isRaa ? "YES" : "NO" |
||
102 | ) |
||
103 | ); |
||
104 | |||
105 | |||
106 | if ($raListing === null) { |
||
107 | $this->logger->notice(sprintf('No RA listing found for IdentityId %s', $identityId)); |
||
108 | return null; |
||
109 | } |
||
110 | |||
111 | $authorizationContextRa = $this->authorizationService->buildInstitutionAuthorizationContext( |
||
112 | new IdentityId($identityId), |
||
113 | InstitutionRole::useRa() |
||
114 | ); |
||
115 | $authorizations = AuthorizedInstitutionCollection::from( |
||
116 | $authorizationContextRa->getInstitutions() |
||
117 | ); |
||
118 | |||
119 | $this->logger->notice(sprintf('IdentityId "%s" is RA for: %s', $identityId, json_encode($authorizationContextRa->getInstitutions()->jsonSerialize()))); |
||
120 | |||
121 | if ($isRaa) { |
||
122 | $authorizationContextRaa = $this->authorizationService->buildInstitutionAuthorizationContext( |
||
123 | new IdentityId($identityId), |
||
124 | InstitutionRole::useRaa() |
||
125 | ); |
||
126 | |||
127 | $this->logger->notice(sprintf('IdentityId "%s" is RAA for: %s', $identityId, json_encode($authorizationContextRaa->getInstitutions()->jsonSerialize()))); |
||
128 | |||
129 | $authorizations = AuthorizedInstitutionCollection::from( |
||
130 | $authorizationContextRa->getInstitutions(), |
||
131 | $authorizationContextRaa->getInstitutions() |
||
132 | ); |
||
133 | } |
||
134 | |||
135 | return new Profile( |
||
136 | $identity, |
||
137 | $authorizations, |
||
138 | $authorizationContextRa->isActorSraa() |
||
139 | ); |
||
155 |