Conditions | 1 |
Paths | 1 |
Total Lines | 52 |
Code Lines | 39 |
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 |
||
52 | private function populateClients() |
||
53 | { |
||
54 | $client = Client::createEmpty(); |
||
55 | $client = $client->create( |
||
56 | ClientId::create('CLIENT_ID_1'), |
||
57 | DataBag::create([ |
||
58 | 'token_endpoint_auth_method' => 'none', |
||
59 | 'grant_types' => [], |
||
60 | ]), |
||
61 | UserAccountId::create('USER_ACCOUNT_1') |
||
62 | ); |
||
63 | $client->eraseMessages(); |
||
64 | $this->save($client); |
||
65 | |||
66 | $client = Client::createEmpty(); |
||
67 | $client = $client->create( |
||
68 | ClientId::create('CLIENT_ID_2'), |
||
69 | DataBag::create([ |
||
70 | 'token_endpoint_auth_method' => 'none', |
||
71 | 'grant_types' => ['client_credentials', 'refresh_token', 'authorization_code', 'password', 'implicit'], |
||
72 | ]), |
||
73 | UserAccountId::create('USER_ACCOUNT_1') |
||
74 | ); |
||
75 | $client->eraseMessages(); |
||
76 | $this->save($client); |
||
77 | |||
78 | $client = Client::createEmpty(); |
||
79 | $client = $client->create( |
||
80 | ClientId::create('CLIENT_ID_3'), |
||
81 | DataBag::create([ |
||
82 | 'token_endpoint_auth_method' => 'client_secret_post', |
||
83 | 'grant_types' => ['client_credentials', 'refresh_token', 'authorization_code', 'password', 'implicit'], |
||
84 | 'client_secret' => 'secret', |
||
85 | ]), |
||
86 | UserAccountId::create('USER_ACCOUNT_1') |
||
87 | ); |
||
88 | $client->eraseMessages(); |
||
89 | $this->save($client); |
||
90 | |||
91 | $client = Client::createEmpty(); |
||
92 | $client = $client->create( |
||
93 | ClientId::create('CLIENT_ID_4'), |
||
94 | DataBag::create([ |
||
95 | 'token_endpoint_auth_method' => 'client_secret_jwt', |
||
96 | 'grant_types' => ['urn:ietf:params:oauth:grant-type:jwt-bearer'], |
||
97 | 'client_secret' => 'secret', |
||
98 | ]), |
||
99 | UserAccountId::create('USER_ACCOUNT_1') |
||
100 | ); |
||
101 | $client->eraseMessages(); |
||
102 | $this->save($client); |
||
103 | } |
||
104 | } |
||
105 |