Conditions | 1 |
Total Lines | 52 |
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 | protected function setUp(): void |
||
44 | { |
||
45 | parent::setUp(); |
||
46 | |||
47 | $this->config = Configuration::loadFromArray( |
||
48 | [ |
||
49 | 'module.enable' => ['memcookie' => true], |
||
50 | ], |
||
51 | '[ARRAY]', |
||
52 | 'simplesaml', |
||
53 | ); |
||
54 | |||
55 | $session = $this->createMock(Session::class); |
||
56 | $session->method('getData')->willReturn(['default-sp' => []]); |
||
57 | /** @var \SimpleSAML\Session $session */ |
||
58 | $this->session = $session; |
||
59 | |||
60 | |||
61 | $this->authsources = Configuration::loadFromArray( |
||
62 | [ |
||
63 | 'default-sp' => ['saml:SP'], |
||
64 | ], |
||
65 | '[ARRAY]', |
||
66 | 'simplesaml', |
||
67 | ); |
||
68 | Configuration::setPreLoadedConfig($this->authsources, 'authsources.php', 'simplesaml'); |
||
69 | |||
70 | $this->http_utils = new class () extends Utils\HTTP { |
||
71 | public function setCookie(string $name, ?string $value, ?array $params = null, bool $throw = true): void |
||
72 | { |
||
73 | // stub |
||
74 | } |
||
75 | |||
76 | public function redirectTrustedURL(string $url, array $parameters = []): void |
||
77 | { |
||
78 | // stub |
||
79 | } |
||
80 | }; |
||
81 | |||
82 | $this->module_config = Configuration::loadFromArray( |
||
83 | [ |
||
84 | 'authsource' => 'default-sp', |
||
85 | 'cookiename' => 'AuthMemCookie', |
||
86 | 'username' => 'uid', |
||
87 | 'groups' => null, |
||
88 | 'memcache.host' => '127.0.0.1', |
||
89 | 'memcache.port' => 11211, |
||
90 | ], |
||
91 | '[ARRAY]', |
||
92 | 'simplesaml', |
||
93 | ); |
||
94 | Configuration::setPreLoadedConfig($this->module_config, 'module_authmemcookie.php', 'simplesaml'); |
||
95 | } |
||
141 |