Conditions | 13 |
Paths | 256 |
Total Lines | 85 |
Code Lines | 45 |
Lines | 18 |
Ratio | 21.18 % |
Changes | 5 | ||
Bugs | 1 | Features | 2 |
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 |
||
13 | public function check() |
||
14 | { |
||
15 | $errors = array(); |
||
16 | |||
17 | // Check for PHP 5.4+ |
||
18 | if (version_compare(phpversion(), '5.5.9', '<=')) { |
||
19 | $errors[] = array( |
||
20 | 'msg' => __('PHP Version is not correct'), |
||
21 | 'details' => __( |
||
22 | 'Symphony requires %1$s or greater to work, however version %2$s was detected.', |
||
23 | array( |
||
24 | '<code><abbr title="PHP: Hypertext Pre-processor">PHP</abbr> 5.5.9</code>', |
||
25 | '<code>' . phpversion() . '</code>' |
||
26 | ) |
||
27 | ) |
||
28 | ); |
||
29 | } |
||
30 | |||
31 | // Is PDO available? |
||
32 | View Code Duplication | if (!extension_loaded('pdo')) { |
|
33 | $errors[] = array( |
||
34 | 'msg' => __('PDO extension not present'), |
||
35 | 'details' => __('Symphony requires PHP to be configured with PDO to work.') |
||
36 | ); |
||
37 | } |
||
38 | |||
39 | // Is CURL available? |
||
40 | View Code Duplication | if (!extension_loaded('curl')) { |
|
41 | $errors[] = array( |
||
42 | 'msg' => __('CURL extension not present'), |
||
43 | 'details' => __('Symphony requires PHP to be configured with CURL for HTTP communication.') |
||
44 | ); |
||
45 | } |
||
46 | |||
47 | // Is libxml available? |
||
48 | View Code Duplication | if (!extension_loaded('xml') && !extension_loaded('libxml')) { |
|
49 | $errors[] = array( |
||
50 | 'msg' => __('XML extension not present'), |
||
51 | 'details' => __('Symphony needs the XML extension to pass data to the site frontend.') |
||
52 | ); |
||
53 | } |
||
54 | |||
55 | // Is libxslt available? |
||
56 | if (!extension_loaded('xsl') && !extension_loaded('xslt') && !function_exists('domxml_xslt_stylesheet')) { |
||
57 | $errors[] = array( |
||
58 | 'msg' => __('XSLT extension not present'), |
||
59 | 'details' => __( |
||
60 | 'Symphony needs an XSLT processor such as %s or Sablotron to build pages.', |
||
61 | array('Lib<abbr title="eXtensible Stylesheet Language Transformation">XSLT</abbr>') |
||
62 | ) |
||
63 | ); |
||
64 | } |
||
65 | |||
66 | // Is json_encode available? |
||
67 | if (!function_exists('json_decode')) { |
||
68 | $errors[] = array( |
||
69 | 'msg' => __('JSON functionality is not present'), |
||
70 | 'details' => __('Symphony uses JSON functionality throughout the backend for translations and the interface.') |
||
71 | ); |
||
72 | } |
||
73 | |||
74 | // Cannot write to root folder. |
||
75 | if (!is_writable(DOCROOT)) { |
||
76 | $errors['no-write-permission-root'] = array( |
||
77 | 'msg' => 'Root folder not writable: ' . DOCROOT, |
||
78 | 'details' => __( |
||
79 | 'Symphony does not have write permission to the root directory. Please modify permission settings on %s. This can be reverted once installation is complete.', |
||
80 | array('<code>' . DOCROOT . '</code>') |
||
81 | ) |
||
82 | ); |
||
83 | } |
||
84 | |||
85 | // Cannot write to workspace |
||
86 | if (is_dir(DOCROOT . '/workspace') && !is_writable(DOCROOT . '/workspace')) { |
||
87 | $errors['no-write-permission-workspace'] = array( |
||
88 | 'msg' => 'Workspace folder not writable: ' . DOCROOT . '/workspace', |
||
89 | 'details' => __( |
||
90 | 'Symphony does not have write permission to the existing %1$s directory. Please modify permission settings on this directory and its contents to allow this, such as with a recursive %2$s command.', |
||
91 | array('<code>/workspace</code>', '<code>chmod -R</code>') |
||
92 | ) |
||
93 | ); |
||
94 | } |
||
95 | |||
96 | return $errors; |
||
97 | } |
||
98 | } |
||
99 |