Passed
Push — developer ( 762b64...a1cff0 )
by Radosław
20:19
created

BaseField   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 9
dl 0
loc 51
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTableName() 0 7 2
A getField() 0 3 1
A getColumnName() 0 3 2
A __construct() 0 4 1
1
<?php
2
/**
3
 * Base query field conditions file.
4
 *
5
 * @package UIType
6
 *
7
 * @copyright YetiForce S.A.
8
 * @license   YetiForce Public License 5.0 (licenses/LicenseEN.txt or yetiforce.com)
9
 * @author    Radosław Skrzypczak <[email protected]>
10
 */
11
12
declare(strict_types=1);
13
14
namespace App\Conditions\QueryFields\Inventory;
15
16
use App\Conditions\QueryFields;
17
18
/**
19
 * Base query field conditions class.
20
 */
21
class BaseField extends QueryFields\BaseField
22
{
23
	/** @var \Vtiger_Basic_InventoryField */
24
	protected $fieldModel;
25
26
	/**
27
	 * Constructor.
28
	 *
29
	 * @param \App\QueryGenerator          $queryGenerator
30
	 * @param \Vtiger_Basic_InventoryField $fieldModel
31
	 * @param array|string                 $value
32
	 * @param string                       $operator
33
	 */
34
	public function __construct(\App\QueryGenerator $queryGenerator, $fieldModel = null)
35
	{
36
		$this->queryGenerator = $queryGenerator;
37
		$this->fieldModel = $fieldModel;
38
	}
39
40
	/**
41
	 * Get column name.
42
	 *
43
	 * @return string
44
	 */
45
	public function getColumnName(): string
46
	{
47
		return $this->fullColumnName ? $this->fullColumnName : $this->fullColumnName = $this->getTableName() . '.' . $this->fieldModel->getColumnName();
48
	}
49
50
	/**
51
	 * Get table name.
52
	 *
53
	 * @return string
54
	 */
55
	public function getTableName(): string
56
	{
57
		if (!$this->tableName) {
58
			$this->tableName = \Vtiger_Inventory_Model::getInstance($this->fieldModel->getModuleName())->getDataTableName();
59
		}
60
61
		return $this->tableName;
62
	}
63
64
	/**
65
	 * Get field model.
66
	 *
67
	 * @return \Vtiger_Basic_InventoryField
68
	 */
69
	public function getField()
70
	{
71
		return $this->fieldModel;
72
	}
73
}
74