| Conditions | 10 |
| Paths | 1 |
| Total Lines | 86 |
| Code Lines | 25 |
| 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 |
||
| 29 | public function __construct() { |
||
| 30 | |||
| 31 | # Admin language |
||
| 32 | |||
| 33 | $this->addParam('admin_language', CONFIG_ADMIN_LANGUAGE_DEFAULT, function (string $name) { |
||
| 34 | |||
| 35 | return ((false !== ($name = Extend\Languages::validate($name))) ? $name : null); |
||
| 36 | }); |
||
| 37 | |||
| 38 | # Admin template |
||
| 39 | |||
| 40 | $this->addParam('admin_template', CONFIG_ADMIN_TEMPLATE_DEFAULT, function (string $name) { |
||
| 41 | |||
| 42 | return ((false !== ($name = Extend\Templates::validate($name))) ? $name : null); |
||
| 43 | }); |
||
| 44 | |||
| 45 | # Site language |
||
| 46 | |||
| 47 | $this->addParam('site_language', CONFIG_SITE_LANGUAGE_DEFAULT, function (string $name) { |
||
| 48 | |||
| 49 | return ((false !== ($name = Extend\Languages::validate($name))) ? $name : null); |
||
| 50 | }); |
||
| 51 | |||
| 52 | # Site template |
||
| 53 | |||
| 54 | $this->addParam('site_template', CONFIG_SITE_TEMPLATE_DEFAULT, function (string $name) { |
||
| 55 | |||
| 56 | return ((false !== ($name = Extend\Templates::validate($name))) ? $name : null); |
||
| 57 | }); |
||
| 58 | |||
| 59 | # Site title |
||
| 60 | |||
| 61 | $this->addParam('site_title', CONFIG_SITE_TITLE_DEFAULT, function (string $title) { |
||
| 62 | |||
| 63 | return (('' !== $title) ? $title : null); |
||
| 64 | }); |
||
| 65 | |||
| 66 | # Site slogan |
||
| 67 | |||
| 68 | $this->addParam('site_slogan', CONFIG_SITE_SLOGAN_DEFAULT, function (string $slogan) { |
||
| 69 | |||
| 70 | return $slogan; |
||
| 71 | }); |
||
| 72 | |||
| 73 | # Site status |
||
| 74 | |||
| 75 | $this->addParam('site_status', STATUS_ONLINE, function (string $status) { |
||
| 76 | |||
| 77 | return ((false !== ($status = Range\Status::validate($status))) ? $status : null); |
||
| 78 | }); |
||
| 79 | |||
| 80 | # Site description |
||
| 81 | |||
| 82 | $this->addParam('site_description', '', function (string $description) { |
||
| 83 | |||
| 84 | return $description; |
||
| 85 | }); |
||
| 86 | |||
| 87 | # Site keywords |
||
| 88 | |||
| 89 | $this->addParam('site_keywords', '', function (string $keywords) { |
||
| 90 | |||
| 91 | return $keywords; |
||
| 92 | }); |
||
| 93 | |||
| 94 | # System url |
||
| 95 | |||
| 96 | $this->addParam('system_url', $this->getSystemUrl(), function (string $url) { |
||
| 97 | |||
| 98 | return ((false !== ($url = Validate::url($url))) ? $url : null); |
||
| 99 | }); |
||
| 100 | |||
| 101 | # System email |
||
| 102 | |||
| 103 | $this->addParam('system_email', $this->getSystemEmail(), function (string $email) { |
||
| 104 | |||
| 105 | return ((false !== ($email = Validate::email($email))) ? $email : null); |
||
| 106 | }); |
||
| 107 | |||
| 108 | # System timezone |
||
| 109 | |||
| 110 | $this->addParam('system_timezone', CONFIG_SYSTEM_TIMEZONE_DEFAULT, function (string $timezone) { |
||
| 111 | |||
| 112 | return ((false !== ($timezone = Timezone::validate($timezone))) ? $timezone : null); |
||
| 113 | }); |
||
| 114 | } |
||
| 115 | } |
||
| 117 |