Conditions | 15 |
Paths | 16384 |
Total Lines | 79 |
Code Lines | 49 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 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 |
||
17 | public static function install(MoufManager $moufManager) |
||
18 | { |
||
19 | // Let's create the renderer |
||
20 | RendererUtils::createPackageRenderer($moufManager, 'mouf/security.forgot-your-password'); |
||
21 | |||
22 | $configManager = $moufManager->getConfigManager(); |
||
23 | |||
24 | $constants = $configManager->getMergedConstants(); |
||
25 | |||
26 | if (!isset($constants['MAIL_FROM'])) { |
||
27 | $configManager->registerConstant("MAIL_FROM", "string", "ro-reply@localhost", "The 'from' value used when sending mails."); |
||
28 | } |
||
29 | |||
30 | $configPhpConstants = $configManager->getDefinedConstants(); |
||
31 | $configPhpConstants['MAIL_FROM'] = true; |
||
32 | $configManager->setDefinedConstants($configPhpConstants); |
||
33 | |||
34 | |||
35 | // These instances are expected to exist when the installer is run. |
||
36 | $defaultTranslationService = $moufManager->getInstanceDescriptor('defaultTranslationService'); |
||
37 | if ($moufManager->has('Mouf\\Security\\DAO\\SecurityUserDao')) { |
||
38 | $Mouf_Security_DAO_SecurityUserDao = $moufManager->getInstanceDescriptor('Mouf\\Security\\DAO\\SecurityUserDao'); |
||
39 | } else { |
||
40 | $Mouf_Security_DAO_SecurityUserDao = null; |
||
41 | } |
||
42 | $swiftMailer = $moufManager->getInstanceDescriptor('swiftMailer'); |
||
43 | $forgotYourPasswordMailTemplate = $moufManager->getInstanceDescriptor('forgotYourPasswordMailTemplate'); |
||
44 | $userService = $moufManager->getInstanceDescriptor('userService'); |
||
45 | $psr_errorLogLogger = $moufManager->getInstanceDescriptor('psr.errorLogLogger'); |
||
46 | $bootstrapTemplate = $moufManager->getInstanceDescriptor('bootstrapTemplate'); |
||
47 | $block_content = $moufManager->getInstanceDescriptor('block.content'); |
||
48 | $twigEnvironment = $moufManager->getInstanceDescriptor('twigEnvironment'); |
||
49 | |||
50 | // Let's create the instances. |
||
51 | $Mouf_Security_Password_PasswordStrengthCheck = InstallUtils::getOrCreateInstance('Mouf\\Security\\Password\\PasswordStrengthCheck', 'Mouf\\Security\\Password\\PasswordStrengthCheck', $moufManager); |
||
52 | $Mouf_Security_Password_ForgotYourPasswordService = InstallUtils::getOrCreateInstance('Mouf\\Security\\Password\\ForgotYourPasswordService', 'Mouf\\Security\\Password\\ForgotYourPasswordService', $moufManager); |
||
53 | $Mouf_Security_Password_ForgotYourPasswordController = InstallUtils::getOrCreateInstance('Mouf\\Security\\Password\\ForgotYourPasswordController', 'Mouf\\Security\\Password\\ForgotYourPasswordController', $moufManager); |
||
54 | |||
55 | // Let's bind instances together. |
||
56 | if (!$Mouf_Security_Password_PasswordStrengthCheck->getConstructorArgumentProperty('translationService')->isValueSet()) { |
||
57 | $Mouf_Security_Password_PasswordStrengthCheck->getConstructorArgumentProperty('translationService')->setValue($defaultTranslationService); |
||
58 | } |
||
59 | if (!$Mouf_Security_Password_ForgotYourPasswordService->getConstructorArgumentProperty('forgetYourPasswordDao')->isValueSet()) { |
||
60 | $Mouf_Security_Password_ForgotYourPasswordService->getConstructorArgumentProperty('forgetYourPasswordDao')->setValue($Mouf_Security_DAO_SecurityUserDao); |
||
61 | } |
||
62 | if (!$Mouf_Security_Password_ForgotYourPasswordService->getConstructorArgumentProperty('swiftMailer')->isValueSet()) { |
||
63 | $Mouf_Security_Password_ForgotYourPasswordService->getConstructorArgumentProperty('swiftMailer')->setValue($swiftMailer); |
||
64 | } |
||
65 | if (!$Mouf_Security_Password_ForgotYourPasswordService->getConstructorArgumentProperty('mailTemplate')->isValueSet()) { |
||
66 | $Mouf_Security_Password_ForgotYourPasswordService->getConstructorArgumentProperty('mailTemplate')->setValue($forgotYourPasswordMailTemplate); |
||
67 | } |
||
68 | if (!$Mouf_Security_Password_ForgotYourPasswordService->getConstructorArgumentProperty('userService')->isValueSet()) { |
||
69 | $Mouf_Security_Password_ForgotYourPasswordService->getConstructorArgumentProperty('userService')->setValue($userService); |
||
70 | } |
||
71 | if (!$Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('logger')->isValueSet()) { |
||
72 | $Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('logger')->setValue($psr_errorLogLogger); |
||
73 | } |
||
74 | if (!$Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('template')->isValueSet()) { |
||
75 | $Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('template')->setValue($bootstrapTemplate); |
||
76 | } |
||
77 | if (!$Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('content')->isValueSet()) { |
||
78 | $Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('content')->setValue($block_content); |
||
79 | } |
||
80 | if (!$Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('twig')->isValueSet()) { |
||
81 | $Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('twig')->setValue($twigEnvironment); |
||
82 | } |
||
83 | if (!$Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('forgotYourPasswordService')->isValueSet()) { |
||
84 | $Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('forgotYourPasswordService')->setValue($Mouf_Security_Password_ForgotYourPasswordService); |
||
85 | } |
||
86 | if (!$Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('userService')->isValueSet()) { |
||
87 | $Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('userService')->setValue($userService); |
||
88 | } |
||
89 | if (!$Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('passwordStrengthCheck')->isValueSet()) { |
||
90 | $Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('passwordStrengthCheck')->setValue($Mouf_Security_Password_PasswordStrengthCheck); |
||
91 | } |
||
92 | |||
93 | // Let's rewrite the MoufComponents.php file to save the component |
||
94 | $moufManager->rewriteMouf(); |
||
95 | } |
||
96 | } |
||
97 |