Competition_Record_Model   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 13
dl 0
loc 24
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getHierarchy() 0 17 3
1
<?php
2
3
/**
4
 * Record Class for Competition.
5
 *
6
 * @copyright YetiForce S.A.
7
 * @license   YetiForce Public License 6.5 (licenses/LicenseEN.txt or yetiforce.com)
8
 * @author    Michał Lorencik <[email protected]>
9
 */
10
class Competition_Record_Model extends Vtiger_Record_Model
11
{
12
	/**
13
	 * Function returns the details of IStorages Hierarchy.
14
	 *
15
	 * @return array
16
	 */
17
	public function getHierarchy()
18
	{
19
		$focus = CRMEntity::getInstance($this->getModuleName());
20
		$hierarchy = $focus->getHierarchy($this->getId());
0 ignored issues
show
Bug introduced by
The method getHierarchy() does not exist on CRMEntity. It seems like you code against a sub-type of CRMEntity such as Contacts or Project or IStorages or MultiCompany or Partners or SSalesProcesses or Competition. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

20
		/** @scrutinizer ignore-call */ 
21
  $hierarchy = $focus->getHierarchy($this->getId());
Loading history...
21
		foreach ($hierarchy['entries'] as $competitionId => $data) {
22
			preg_match('/<a href="+/', $data[0], $matches);
23
			if (!empty($matches)) {
24
				preg_match('/[.\s]+/', $data[0], $dashes);
25
				preg_match('/<a(.*)>(.*)<\\/a>/i', $data[0], $name);
26
27
				$recordModel = Vtiger_Record_Model::getCleanInstance('Competition');
28
				$recordModel->setId($competitionId);
29
				$hierarchy['entries'][$competitionId][0] = ($dashes[0] ?? '') . '<a href=' . $recordModel->getDetailViewUrl() . '>' . $name[2] .
30
					'</a>';
31
			}
32
		}
33
		return $hierarchy;
34
	}
35
}
36