Passed
Push — developer ( c475b4...5772fb )
by Mariusz
69:56 queued 34:42
created

LibraryLicense::getModalIcon()   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(): void
22
	{
23
	}
24
25
	/**  {@inheritdoc}  */
26
	public function getTitle(): string
27
	{
28
		return \App\Language::translate('LBL_LICENSE', $this->moduleName);
29
	}
30
31
	/** {@inheritdoc} */
32
	public function validateRequest(): void
33
	{
34
		$this->request->validateWriteAccess();
35
	}
36
37
	/** {@inheritdoc} */
38
	public function getModalSize(): string
39
	{
40
		return 'modal-lg';
41
	}
42
43
	/** {@inheritdoc} */
44
	public function getModalIcon(): string
45
	{
46
		return 'fab fa-wpforms';
47
	}
48
49
	/** {@inheritdoc} */
50
	public function process(): void
51
	{
52
		$fileContent = '';
53
		if ($this->request->isEmpty('license')) {
54
			$result = false;
55
		} else {
56
			$dir = ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . 'licenses' . \DIRECTORY_SEPARATOR;
57
			$filePath = $dir . $this->request->get('license', 'Text') . '.txt';
58 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...
59
				$result = true;
60
				$fileContent = file_get_contents($filePath);
61
			} else {
62
				$result = false;
63
			}
64
		}
65
66
		$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...
67
		$this->viewer->assign('QUALIFIED_MODULE', $moduleName);
68
		$this->viewer->assign('FILE_EXIST', $result);
69
		$this->viewer->assign('FILE_CONTENT', $fileContent);
70
		$this->viewer->view('LibraryLicense.tpl', $moduleName);
71
	}
72
}
73