| Conditions | 1 |
| Paths | 1 |
| Total Lines | 54 |
| Code Lines | 49 |
| 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 |
||
| 20 | public function testEntity() |
||
| 21 | { |
||
| 22 | $client = new Client(); |
||
| 23 | $client->getOwners()->add((new Person())->setEmail('[email protected]')); |
||
| 24 | |||
| 25 | /** @var ClientMetadata $metadata */ |
||
| 26 | $metadata = (new ClientMetadata()) |
||
| 27 | ->setId($id = 'my id') |
||
| 28 | ->setClientId($clientId = 'the.client.id') |
||
| 29 | ->setClientSecret($clientSecret = 'super secret') |
||
| 30 | ->setClient($client) |
||
| 31 | ->setRedirectUris($uris = ['https://example.com/']) |
||
| 32 | ->setContacts($contacts = ['[email protected]']) |
||
| 33 | ->setLogoUri($logoUri = 'https://example.com/mylogo.png') |
||
| 34 | ->setClientUri($clientUri = 'https://example.com') |
||
| 35 | ->setPolicyUri($policyUri = 'https://example.com/policy') |
||
| 36 | ->setTosUri($tosUri = 'https://example.com/tos') |
||
| 37 | ->setJwksUri($jwksUri = 'https://example.com/jwks') |
||
| 38 | ->setJwks($jwks = 'something') |
||
| 39 | ->setSectorIdentifierUri($sectorIdentifierUri = 'https://example.com/sector') |
||
| 40 | ->setIdTokenEncryptedResponseAlg('ALG') |
||
| 41 | ->setIdTokenEncryptedResponseEnc('ENC') |
||
| 42 | ->setUserinfoSignedResponseAlg('ALG') |
||
| 43 | ->setUserinfoEncryptedResponseAlg('ALG') |
||
| 44 | ->setUserinfoEncryptedResponseEnc('ENC') |
||
| 45 | ->setRequestObjectSigningAlg('ALG') |
||
| 46 | ->setRequestObjectEncryptionAlg('ALG') |
||
| 47 | ->setRequestObjectEncryptionEnc('ENC') |
||
| 48 | ->setTokenEndpointAuthSigningAlg('ALG') |
||
| 49 | ->setDefaultMaxAge(12345) |
||
| 50 | ->setDefaultAcrValues([]) |
||
| 51 | ->setInitiateLoginUri($loginUri = 'https://example.com/login') |
||
| 52 | ->setRegistrationAccessToken($regAccessToken = 'accessToken') |
||
| 53 | ->setPostLogoutRedirectUris($uris); |
||
| 54 | $metadata->checkDefaults(); |
||
| 55 | |||
| 56 | $this->assertSame($clientId, $metadata->getClientId()); |
||
| 57 | $this->assertSame($clientSecret, $metadata->getClientSecret()); |
||
| 58 | $this->assertSame($client, $metadata->getClient()); |
||
| 59 | $this->assertSame($uris, $metadata->getRedirectUris()); |
||
| 60 | $this->assertContains('[email protected]', $metadata->getContacts()); |
||
| 61 | $this->assertSame($logoUri, $metadata->getLogoUri()); |
||
| 62 | $this->assertSame($clientUri, $metadata->getClientUri()); |
||
| 63 | $this->assertSame($policyUri, $metadata->getPolicyUri()); |
||
| 64 | $this->assertSame($tosUri, $metadata->getTosUri()); |
||
| 65 | $this->assertSame($jwksUri, $metadata->getJwksUri()); |
||
| 66 | $this->assertSame($jwks, $metadata->getJwks()); |
||
| 67 | $this->assertSame($sectorIdentifierUri, $metadata->getSectorIdentifierUri()); |
||
| 68 | $this->assertSame(12345, $metadata->getDefaultMaxAge()); |
||
| 69 | $this->assertSame($loginUri, $metadata->getInitiateLoginUri()); |
||
| 70 | $this->assertSame($regAccessToken, $metadata->getRegistrationAccessToken()); |
||
| 71 | $this->assertSame($uris, $metadata->getPostLogoutRedirectUris()); |
||
| 72 | $this->assertSame('pairwise', $metadata->getSubjectType()); |
||
| 73 | $this->assertSame('example.com', $metadata->getSectorIdentifier()); |
||
| 74 | } |
||
| 76 |