Test Setup Failed
Pull Request — developer (#249)
by Arkadiusz
06:57
created

LibraryLicense::checkPermission()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * Library license view file.
5
 *
6
 * @package View
7
 *
8
 * @copyright YetiForce Sp. z o.o
9
 * @license   YetiForce Public License 3.0 (licenses/LicenseEN.txt or yetiforce.com)
10
 * @author    Arkadiusz Sołek <[email protected]>
11
 */
12
13
namespace YF\Modules\YetiForce\View;
14
15
/**
16
 * Library license view class.
17
 */
18
class LibraryLicense extends \App\Controller\Modal
19
{
20
	/** {@inheritdoc} */
21
	public function checkPermission(): bool
0 ignored issues
show
Coding Style introduced by
function checkPermission() does not seem to conform to the naming convention (^(?:is|has|should|may|supports)).

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...
22
	{
23
		return true;
24
	}
25
26
	/**  {@inheritdoc}  */
27
	public function getTitle(): string
28
	{
29
		return \App\Language::translate('LBL_LICENSE', $this->moduleName);
30
	}
31
32
	/** {@inheritdoc} */
33
	public function validateRequest(): void
34
	{
35
		$this->request->validateWriteAccess();
36
	}
37
38
	/** {@inheritdoc} */
39
	public function getModalSize(): string
40
	{
41
		return 'modal-lg';
42
	}
43
44
	/** {@inheritdoc} */
45
	public function process(): void
46
	{
47
		$fileContent = '';
48
		if ($this->request->isEmpty('license')) {
49
			$result = false;
50
		} else {
51
			$dir = ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . 'licenses' . \DIRECTORY_SEPARATOR;
52
			$filePath = $dir . $this->request->get('license', 'Text') . '.txt';
53 View Code Duplication
			if (file_exists($filePath)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
54
				$result = true;
55
				$fileContent = file_get_contents($filePath);
56
			} else {
57
				$result = false;
58
			}
59
		}
60
61
		$moduleName = $this->request->getModule(false);
0 ignored issues
show
Unused Code introduced by
The call to Request::getModule() has too many arguments starting with false.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
62
		$this->viewer->assign('QUALIFIED_MODULE', $moduleName);
63
		$this->viewer->assign('FILE_EXIST', $result);
64
		$this->viewer->assign('FILE_CONTENT', $fileContent);
65
		$this->viewer->view('LibraryLicense.tpl', $moduleName);
66
	}
67
}
68