Conditions | 1 |
Paths | 1 |
Total Lines | 60 |
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 |
||
43 | public function theRequestIsValidButNoAccountIsSelected() |
||
44 | { |
||
45 | $uri = $this->buildUri([ |
||
46 | 'client_id' => 'CLIENT_ID_2', |
||
47 | 'redirect_uri' => 'https://example.com/cb/?foo=bar', |
||
48 | 'response_type' => 'code', |
||
49 | ]); |
||
50 | $client = static::createClient(); |
||
51 | $this->logIn( |
||
52 | $client, |
||
53 | new User( |
||
54 | 'admin', |
||
55 | ['ROLE_ADMIN', 'ROLE_USER'], |
||
56 | ['john.1'], |
||
57 | new \DateTimeImmutable('now -25 hours'), |
||
58 | new \DateTimeImmutable('now -15 days') |
||
59 | ), |
||
60 | new UserAccount( |
||
61 | new UserAccountId('john.1'), |
||
62 | [ |
||
63 | 'address', [ |
||
64 | 'street_address' => '5 rue Sainte Anne', |
||
65 | 'region' => 'Île de France', |
||
66 | 'postal_code' => '75001', |
||
67 | 'locality' => 'Paris', |
||
68 | 'country' => 'France', |
||
69 | ], |
||
70 | 'name' => 'John Doe', |
||
71 | 'given_name' => 'John', |
||
72 | 'family_name' => 'Doe', |
||
73 | 'middle_name' => 'Jack', |
||
74 | 'nickname' => 'Little John', |
||
75 | 'profile' => 'https://profile.doe.fr/john/', |
||
76 | 'preferred_username' => 'j-d', |
||
77 | 'gender' => 'M', |
||
78 | 'phone_number' => '+0123456789', |
||
79 | 'phone_number_verified' => true, |
||
80 | 'zoneinfo' => 'Europe/Paris', |
||
81 | 'locale' => 'en', |
||
82 | 'picture' => 'https://www.google.com', |
||
83 | 'birthdate' => '1950-01-01', |
||
84 | 'email' => '[email protected]', |
||
85 | 'email_verified' => false, |
||
86 | 'website' => 'https://john.doe.com', |
||
87 | 'website#fr_fr' => 'https://john.doe.fr', |
||
88 | 'website#fr' => 'https://john.doe.fr', |
||
89 | 'picture#de' => 'https://john.doe.de/picture', |
||
90 | ] |
||
91 | ) |
||
92 | ); |
||
93 | $client->request('GET', $uri, [], [], ['HTTPS' => 'on'], null); |
||
94 | $response = $client->getResponse(); |
||
95 | |||
96 | static::assertEquals(303, $response->getStatusCode()); |
||
97 | static::assertTrue($response->headers->has('location')); |
||
98 | |||
99 | $client->followRedirect(); |
||
100 | $response = $client->getResponse(); |
||
101 | dump($response->headers->get('location')); |
||
102 | } |
||
103 | |||
127 |