| Conditions | 12 |
| Paths | 1 |
| Total Lines | 100 |
| Code Lines | 29 |
| 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 |
||
| 42 | public function __construct() { |
||
| 43 | |||
| 44 | # Site language |
||
| 45 | |||
| 46 | $this->addParam('site_language', CONFIG_SITE_LANGUAGE, function (string $name) { |
||
| 47 | |||
| 48 | return ((false !== ($name = Extend\Languages::validate($name))) ? $name : null); |
||
| 49 | }); |
||
| 50 | |||
| 51 | # Site template |
||
| 52 | |||
| 53 | $this->addParam('site_template', CONFIG_SITE_TEMPLATE, function (string $name) { |
||
| 54 | |||
| 55 | return ((false !== ($name = Extend\Templates::validate($name))) ? $name : null); |
||
| 56 | }); |
||
| 57 | |||
| 58 | # Site title |
||
| 59 | |||
| 60 | $this->addParam('site_title', CONFIG_SITE_TITLE, function (string $title) { |
||
| 61 | |||
| 62 | return (('' !== $title) ? $title : null); |
||
| 63 | }); |
||
| 64 | |||
| 65 | # Site slogan |
||
| 66 | |||
| 67 | $this->addParam('site_slogan', CONFIG_SITE_SLOGAN, function (string $slogan) { |
||
| 68 | |||
| 69 | return $slogan; |
||
| 70 | }); |
||
| 71 | |||
| 72 | # Site status |
||
| 73 | |||
| 74 | $this->addParam('site_status', CONFIG_SITE_STATUS, function (int $status) { |
||
| 75 | |||
| 76 | return ((false !== ($status = Range\Status::validate($status))) ? $status : null); |
||
| 77 | }); |
||
| 78 | |||
| 79 | # Site description |
||
| 80 | |||
| 81 | $this->addParam('site_description', CONFIG_SITE_DESCRIPTION, function (string $description) { |
||
| 82 | |||
| 83 | return $description; |
||
| 84 | }); |
||
| 85 | |||
| 86 | # Site keywords |
||
| 87 | |||
| 88 | $this->addParam('site_keywords', CONFIG_SITE_KEYWORDS, function (string $keywords) { |
||
| 89 | |||
| 90 | return $keywords; |
||
| 91 | }); |
||
| 92 | |||
| 93 | # System url |
||
| 94 | |||
| 95 | $this->addParam('system_url', $this->getSystemUrl(), function (string $url) { |
||
| 96 | |||
| 97 | return ((false !== ($url = Validate::url($url))) ? $url : null); |
||
| 98 | }); |
||
| 99 | |||
| 100 | # System email |
||
| 101 | |||
| 102 | $this->addParam('system_email', $this->getSystemEmail(), function (string $email) { |
||
| 103 | |||
| 104 | return ((false !== ($email = Validate::email($email))) ? $email : null); |
||
| 105 | }); |
||
| 106 | |||
| 107 | # System timezone |
||
| 108 | |||
| 109 | $this->addParam('system_timezone', CONFIG_SYSTEM_TIMEZONE, function (string $timezone) { |
||
| 110 | |||
| 111 | return ((false !== ($timezone = Timezone::validate($timezone))) ? $timezone : null); |
||
| 112 | }); |
||
| 113 | |||
| 114 | # Admin language |
||
| 115 | |||
| 116 | $this->addParam('admin_language', CONFIG_ADMIN_LANGUAGE, function (string $name) { |
||
| 117 | |||
| 118 | return ((false !== ($name = Extend\Languages::validate($name))) ? $name : null); |
||
| 119 | }); |
||
| 120 | |||
| 121 | # Admin template |
||
| 122 | |||
| 123 | $this->addParam('admin_template', CONFIG_ADMIN_TEMPLATE, function (string $name) { |
||
| 124 | |||
| 125 | return ((false !== ($name = Extend\Templates::validate($name))) ? $name : null); |
||
| 126 | }); |
||
| 127 | |||
| 128 | # Admin display entities |
||
| 129 | |||
| 130 | $this->addParam('admin_display_entities', CONFIG_ADMIN_DISPLAY_ENTITIES, function (int $display) { |
||
| 131 | |||
| 132 | return ((false !== ($display = Range\Display\Entities::validate($display))) ? $display : null); |
||
| 133 | }); |
||
| 134 | |||
| 135 | # Admin display files |
||
| 136 | |||
| 137 | $this->addParam('admin_display_files', CONFIG_ADMIN_DISPLAY_FILES, function (int $display) { |
||
| 138 | |||
| 139 | return ((false !== ($display = Range\Display\Files::validate($display))) ? $display : null); |
||
| 140 | }); |
||
| 141 | } |
||
| 142 | } |
||
| 144 |