Conditions | 1 |
Paths | 1 |
Total Lines | 94 |
Code Lines | 72 |
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 |
||
42 | public function __construct(EventStoreInterface $eventStore, RecordsMessages $eventRecorder) |
||
43 | { |
||
44 | $this->eventStore = $eventStore; |
||
45 | $this->eventRecorder = $eventRecorder; |
||
46 | $this->createAndSaveClient( |
||
47 | ClientId::create('client1'), |
||
48 | DataBag::createFromArray([ |
||
49 | 'token_endpoint_auth_method' => 'client_secret_basic', |
||
50 | 'client_secret' => 'secret', |
||
51 | 'grant_types' => ['client_credentials', 'password', 'refresh_token', 'authorization_code', 'urn:ietf:params:oauth:grant-type:jwt-bearer'], |
||
52 | 'response_types' => ['code', 'token', 'id_token', 'code token', 'code id_token', 'id_token token', 'code id_token token', 'none'], |
||
53 | 'redirect_uris' => ['https://example.com/'], |
||
54 | 'id_token_signed_response_alg' => 'ES256', |
||
55 | ]), |
||
56 | UserAccountId::create('User1') |
||
57 | ); |
||
58 | |||
59 | $this->createAndSaveClient( |
||
60 | ClientId::create('client2'), |
||
61 | DataBag::createFromArray([ |
||
62 | 'token_endpoint_auth_method' => 'none', |
||
63 | 'grant_types' => ['client_credentials', 'authorization_code'], |
||
64 | 'userinfo_signed_response_alg' => 'none', |
||
65 | ]), |
||
66 | UserAccountId::create('User1') |
||
67 | ); |
||
68 | |||
69 | $this->createAndSaveClient( |
||
70 | ClientId::create('client3'), |
||
71 | DataBag::createFromArray([ |
||
72 | 'token_endpoint_auth_method' => 'client_secret_jwt', |
||
73 | 'client_secret' => 'secret', |
||
74 | 'client_secret_expires_at' => (new \DateTimeImmutable('now + 1 day'))->getTimestamp(), |
||
75 | 'grant_types' => ['client_credentials', 'password', 'refresh_token', 'authorization_code'], |
||
76 | ]), |
||
77 | UserAccountId::create('User1') |
||
78 | ); |
||
79 | |||
80 | $this->createAndSaveClient( |
||
81 | ClientId::create('client4'), |
||
82 | DataBag::createFromArray([ |
||
83 | 'token_endpoint_auth_method' => 'client_secret_post', |
||
84 | 'client_secret' => 'secret', |
||
85 | 'client_secret_expires_at' => (new \DateTimeImmutable('now + 1 day'))->getTimestamp(), |
||
86 | ]), |
||
87 | UserAccountId::create('User1') |
||
88 | ); |
||
89 | |||
90 | $this->createAndSaveClient( |
||
91 | ClientId::create('79b407fb-acc0-4880-ab98-254062c214ce'), |
||
92 | DataBag::createFromArray([ |
||
93 | 'registration_access_token' => 'JNWuIxHkTKtUmmtEpipDtPlTc3ordUNpSVVPLbQXKrFKyYVDR7N3k1ZzrHmPWXoibr2J2HrTSSozN6zIhHuypA', |
||
94 | 'grant_types' => [], |
||
95 | 'response_types' => [], |
||
96 | 'redirect_uris' => ['https://www.foo.com'], |
||
97 | 'software_statement' => 'eyJhbGciOiJFUzI1NiJ9.eyJzb2Z0d2FyZV92ZXJzaW9uIjoiMS4wIiwic29mdHdhcmVfbmFtZSI6Ik15IGFwcGxpY2F0aW9uIiwic29mdHdhcmVfbmFtZSNlbiI6Ik15IGFwcGxpY2F0aW9uIiwic29mdHdhcmVfbmFtZSNmciI6Ik1vbiBhcHBsaWNhdGlvbiJ9.88m8-YyguCCx1QNChwfNnMZ9APKpNC--nnfB1rVBpAYyHLixtsyMuuI09svqxuiRfTxwgXuRUvsg_5RozmtusQ', |
||
98 | 'software_version' => '1.0', |
||
99 | 'software_name' => 'My application', |
||
100 | 'software_name#en' => 'My application', |
||
101 | 'software_name#fr' => 'Mon application', |
||
102 | 'registration_client_uri' => 'https://www.config.example.com/client/79b407fb-acc0-4880-ab98-254062c214ce', |
||
103 | 'client_id_issued_at' => 1482177703, |
||
104 | ]), |
||
105 | UserAccountId::create('User1') |
||
106 | ); |
||
107 | |||
108 | $this->createAndSaveClient( |
||
109 | ClientId::create('DISABLED_CLIENT'), |
||
110 | DataBag::createFromArray([ |
||
111 | 'token_endpoint_auth_method' => 'client_secret_basic', |
||
112 | 'client_secret' => 'secret', |
||
113 | 'grant_types' => ['client_credentials', 'password', 'refresh_token', 'authorization_code', 'urn:ietf:params:oauth:grant-type:jwt-bearer'], |
||
114 | 'response_types' => ['code', 'token', 'id_token', 'code token', 'code id_token', 'id_token token', 'code id_token token', 'none'], |
||
115 | 'redirect_uris' => ['https://example.com/'], |
||
116 | 'id_token_signed_response_alg' => 'ES256', |
||
117 | ]), |
||
118 | UserAccountId::create('User1'), |
||
119 | true |
||
120 | ); |
||
121 | |||
122 | $this->createAndSaveClient( |
||
123 | ClientId::create('client5'), |
||
124 | DataBag::createFromArray([ |
||
125 | 'token_endpoint_auth_method' => 'client_secret_basic', |
||
126 | 'client_secret' => 'secret', |
||
127 | 'client_secret_expires_at' => time() - 100, |
||
128 | 'grant_types' => ['client_credentials', 'password', 'refresh_token', 'authorization_code', 'urn:ietf:params:oauth:grant-type:jwt-bearer'], |
||
129 | 'response_types' => ['code', 'token', 'id_token', 'code token', 'code id_token', 'id_token token', 'code id_token token', 'none'], |
||
130 | 'redirect_uris' => ['https://example.com/'], |
||
131 | 'id_token_signed_response_alg' => 'ES256', |
||
132 | ]), |
||
133 | UserAccountId::create('User1') |
||
134 | ); |
||
135 | } |
||
136 | |||
186 |