Passed
Push — developer ( 6b5868...bed0f9 )
by Radosław
22:42 queued 03:39
created

Settings_MailSmtp_Module_Model::getFieldInstanceByName()   F

Complexity

Conditions 28
Paths 54

Size

Total Lines 323
Code Lines 290

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 812

Importance

Changes 0
Metric Value
eloc 290
dl 0
loc 323
rs 3.3333
c 0
b 0
f 0
ccs 0
cts 0
cp 0
cc 28
nc 54
nop 1
crap 812

How to fix   Long Method    Complexity   

Long Method

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:

1
<?php
2
3
/**
4
 * MailSmtp module model class.
5
 *
6
 * @copyright YetiForce S.A.
7
 * @license YetiForce Public License 6.5 (licenses/LicenseEN.txt or yetiforce.com)
8
 * @author Adrian Koń <[email protected]>
9
 */
10
class Settings_MailSmtp_Module_Model extends Settings_Vtiger_Module_Model
11
{
12
	public $baseTable = 's_#__mail_smtp';
13
	public $baseIndex = 'id';
14
	public $listFields = ['name' => 'LBL_NAME', 'host' => 'LBL_HOST', 'port' => 'LBL_PORT', 'username' => 'LBL_USERNAME', 'from_email' => 'LBL_FROM_EMAIL', 'default' => 'LBL_DEFAULT'];
15
	public $name = 'MailSmtp';
16
17
	/**
18
	 * Function to get the url for default view of the module.
19
	 *
20
	 * @return string URL
21
	 */
22
	public function getDefaultUrl()
23
	{
24
		return 'index.php?module=MailSmtp&parent=Settings&view=List';
25
	}
26
27
	/**
28
	 * Function to get the url for create view of the module.
29
	 *
30
	 * @return string URL
31
	 */
32
	public function getCreateRecordUrl()
33
	{
34
		return 'index.php?module=MailSmtp&parent=Settings&view=Edit';
35
	}
36
37
	public static function getSmtpNames()
38
	{
39
		return (new \App\Db\Query())->select(['id', 'name'])->from('s_#__mail_smtp')->all(\App\Db::getInstance('admin'));
40
	}
41
}
42