Conditions | 10 |
Paths | 64 |
Total Lines | 86 |
Code Lines | 62 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
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 |
||
18 | public function up(Schema $schema): void |
||
19 | { |
||
20 | $projectDir = $this->container->getParameter('kernel.project_dir'); |
||
|
|||
21 | $updateRootPath = $this->getUpdateRootPath(); |
||
22 | $oldMailConfPath = $updateRootPath.'/app/config/mail.conf.php'; |
||
23 | |||
24 | $legacyMailConfig = file_exists($oldMailConfPath); |
||
25 | |||
26 | if ($legacyMailConfig) { |
||
27 | include $oldMailConfPath; |
||
28 | |||
29 | global $platform_email; |
||
30 | } |
||
31 | |||
32 | $envFile = $projectDir.'/.env'; |
||
33 | |||
34 | $dotenv = new Dotenv(); |
||
35 | $dotenv->loadEnv($envFile); |
||
36 | |||
37 | $mailerScheme = 'null'; |
||
38 | $smtpSecure = $_ENV['SMTP_SECURE'] ?? ''; |
||
39 | $query = ''; |
||
40 | |||
41 | if (!empty($smtpSecure)) { |
||
42 | $mailerScheme = 'smtp'; |
||
43 | |||
44 | if ($smtpSecure === 'ssl') { |
||
45 | $mailerScheme = 'smtps'; |
||
46 | } elseif ($smtpSecure === 'tls') { |
||
47 | $query = '?encryption=tls'; |
||
48 | } |
||
49 | } |
||
50 | |||
51 | $dsn = sprintf( |
||
52 | '%s://%s%s@%s:%s%s', |
||
53 | $mailerScheme, |
||
54 | !empty($_ENV['SMTP_AUTH']) ? ($_ENV['SMTP_USER'] ?? '') : '', |
||
55 | !empty($_ENV['SMTP_AUTH']) ? ':'.($_ENV['SMTP_PASS'] ?? '') : '', |
||
56 | $_ENV['SMTP_HOST'] ?? '', |
||
57 | $_ENV['SMTP_PORT'] ?? '', |
||
58 | $query |
||
59 | ); |
||
60 | |||
61 | $settings = [ |
||
62 | 'mailer_from_email' => $_ENV['SMTP_FROM_EMAIL'] ?? '', |
||
63 | 'mailer_from_name' => $_ENV['SMTP_FROM_NAME'] ?? '', |
||
64 | 'mailer_dsn' => $dsn, |
||
65 | 'mailer_mails_charset' => $_ENV['SMTP_CHARSET'] ?? 'UTF-8', |
||
66 | 'mailer_debug_enable' => !empty($_ENV['SMTP_DEBUG']) ? 'true' : 'false', |
||
67 | 'mailer_exclude_json' => $platform_email['EXCLUDE_JSON'] ?? false, |
||
68 | 'mailer_dkim' => '', |
||
69 | 'mailer_xoauth2' => '', |
||
70 | ]; |
||
71 | |||
72 | if ($legacyMailConfig) { |
||
73 | $dkim = [ |
||
74 | 'enable' => $platform_email['DKIM'] ?? false, |
||
75 | 'selector' => $platform_email['DKIM_SELECTOR'] ?? '', |
||
76 | 'domain' => $platform_email['DKIM_DOMAIN'] ?? '', |
||
77 | 'private_key_string' => $platform_email['DKIM_PRIVATE_KEY_STRING'] ?? '', |
||
78 | 'private_key' => $platform_email['DKIM_PRIVATE_KEY'] ?? '', |
||
79 | 'passphrase' => $platform_email['DKIM_PASSPHRASE'] ?? '', |
||
80 | ]; |
||
81 | |||
82 | $xoauth2 = [ |
||
83 | 'method' => $platform_email['XOAUTH2_METHOD'] ?? false, |
||
84 | 'url_authorize' => $platform_email['XOAUTH2_URL_AUTHORIZE'] ?? '', |
||
85 | 'url_access_token' => $platform_email['XOAUTH2_URL_ACCES_TOKEN'] ?? '', |
||
86 | 'url_resource_owner_details' => $platform_email['XOAUTH2_URL_RESOURCE_OWNER_DETAILS'] ?? '', |
||
87 | 'scopes' => $platform_email['XOAUTH2_SCOPES'] ?? '', |
||
88 | 'client_id' => $platform_email['XOAUTH2_CLIENT_ID'] ?? '', |
||
89 | 'client_secret' => $platform_email['XOAUTH2_CLIENT_SECRET'] ?? '', |
||
90 | 'refresh_token' => $platform_email['XOAUTH2_REFRESH_TOKEN'] ?? '', |
||
91 | ]; |
||
92 | |||
93 | $settings['mailer_dkim'] = json_encode($dkim); |
||
94 | $settings['mailer_xoauth2'] = json_encode($xoauth2); |
||
95 | |||
96 | } |
||
97 | foreach ($settings as $variable => $value) { |
||
98 | $this->addSql( |
||
99 | sprintf( |
||
100 | "INSERT IGNORE INTO settings (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url, access_url_changeable, access_url_locked) VALUES ('%s', null, null, 'mail', %s, '%s', null, '', null, 1, 1, 1)", |
||
101 | $variable, |
||
102 | $value, |
||
103 | $variable |
||
104 | ), |
||
108 | } |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.