Conditions | 4 |
Paths | 4 |
Total Lines | 54 |
Code Lines | 42 |
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 |
||
67 | public function createIdentity(User $user) |
||
68 | { |
||
69 | if ($user->getIdentityUuid()) { |
||
70 | throw new LogicException('Identity "'.$user->getIdentityUuid().'" already exists.'); |
||
71 | } |
||
72 | |||
73 | switch ($user->getIdentity()) { |
||
74 | case Identity::INDIVIDUAL: |
||
75 | $identity = new Individual; |
||
76 | $identity |
||
77 | ->setOwner($user->getOwner()) |
||
78 | ->setOwnerUuid($user->getOwnerUuid()); |
||
79 | $identity = $this->api->get('identities.individual')->create($identity); |
||
80 | $persona = new IndividualPersona; |
||
81 | $persona |
||
82 | ->setOwner($user->getOwner()) |
||
83 | ->setOwnerUuid($user->getOwnerUuid()) |
||
84 | ->setIndividual($identity) |
||
85 | ->setTitle([ // @todo remove hard-coded titles |
||
86 | 'en' => 'Default', |
||
87 | 'fr' => 'Défaut' |
||
88 | ]) |
||
89 | ->setData($user->getRegistration()->getData()); |
||
90 | $this->api->get('identities.individual_persona')->create($persona); |
||
91 | break; |
||
92 | |||
93 | case Identity::ORGANIZATION: |
||
94 | $identity = new Organization; |
||
95 | $identity |
||
96 | ->setOwner($user->getOwner()) |
||
97 | ->setOwnerUuid($user->getOwnerUuid()); |
||
98 | $identity = $this->api->get('identities.organization')->create($identity); |
||
99 | |||
100 | $persona = new OrganizationPersona; |
||
101 | $persona |
||
102 | ->setOwner($user->getOwner()) |
||
103 | ->setOwnerUuid($user->getOwnerUuid()) |
||
104 | ->setOrganization($identity) |
||
105 | ->setTitle([ // @todo remove hard-coded titles |
||
106 | 'en' => 'Default', |
||
107 | 'fr' => 'Défaut' |
||
108 | ]) |
||
109 | ->setData($user->getRegistration()->getData()); |
||
110 | $this->api->get('identities.organization_persona')->create($persona); |
||
111 | break; |
||
112 | |||
113 | default: |
||
114 | throw new DomainException('User identity "'.$user->getIdentity().'" is not supported.'); |
||
115 | } |
||
116 | |||
117 | $user->setIdentityUuid($identity->getUuid()); |
||
118 | $this->customManager->updateUser($user); |
||
119 | |||
120 | return $identity; |
||
121 | } |
||
123 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths