Passed
Push — developer ( 2e4efd...3d8f05 )
by Mariusz
151:22 queued 116:22
created

Loader::import()   B

Complexity

Conditions 6
Paths 10

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 8.9777
c 0
b 0
f 0
cc 6
nc 10
nop 2
1
<?php
2
/**
3
 * System files loader.
4
 *
5
 * @copyright YetiForce Sp. z o.o.
6
 * @license   YetiForce Public License 3.0 (licenses/LicenseEN.txt or yetiforce.com)
7
 * @author    Mariusz Krzaczkowski <[email protected]>
8
 */
9
10
namespace App;
11
12
class Loader
0 ignored issues
show
Coding Style introduced by
Loader does not seem to conform to the naming convention (Utils?$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
13
{
14
	protected static $includeCache = [];
15
16
	/**
17
	 * Get the class name for the module.
18
	 *
19
	 * @param string $moduleName
20
	 * @param string $moduleType
21
	 * @param string $fieldName
22
	 *
23
	 * @return string
24
	 */
25
	public static function getModuleClassName(string $moduleName, string $moduleType, string $fieldName): string
26
	{
27
		$filePath = ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . 'modules' . \DIRECTORY_SEPARATOR . $moduleName . \DIRECTORY_SEPARATOR . $moduleType . \DIRECTORY_SEPARATOR . $fieldName . '.php';
28
		if (file_exists($filePath)) {
29
			return '\\YF\\Modules' . '\\' . $moduleName . '\\' . $moduleType . '\\' . $fieldName;
30
		}
31
		$filePath = ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . 'modules' . \DIRECTORY_SEPARATOR . 'Base' . \DIRECTORY_SEPARATOR . $moduleType . \DIRECTORY_SEPARATOR . $fieldName . '.php';
32
		if (file_exists($filePath)) {
33
			return '\\YF\\Modules\\Base' . '\\' . $moduleType . '\\' . $fieldName;
34
		}
35
		throw new Exceptions\AppException("HANDLER_NOT_FOUND: $moduleName, $moduleType, $fieldName");
36
	}
37
}
38