Passed
Push — master ( a82a12...289cbe )
by Anton
03:10
created

Edit   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 18 2
1
<?php
2
3
/**
4
 * @package Cadmium\System\Modules\Filemanager
5
 * @author Anton Romanov
6
 * @copyright Copyright (c) 2015-2017, Anton Romanov
7
 * @link http://cadmium-cms.com
8
 */
9
10
namespace Modules\Filemanager\Controller {
11
12
	use Modules\Filemanager;
13
14
	class Edit {
15
16
		protected $parent = null, $entity = null;
17
18
		/**
19
		 * Constructor
20
		 */
21
22
		public function __construct(Filemanager\Utils\Entity $entity) {
23
24
			$this->parent = $entity->getParent(); $this->entity = $entity;
25
		}
26
27
		/**
28
		 * Invoker
29
		 *
30
		 * @return true|string|array : true on success, otherwise an error code, or an array of type [$param_name, $error_code],
31
		 *         where $param_name is a name of param that has triggered the error,
32
		 *         and $error_code is a language phrase related to the error
33
		 */
34
35
		public function __invoke(array $post) {
36
37
			# Declare variables
38
39
			$contents = '';
40
41
			# Extract post array
42
43
			extract($post);
44
45
			# Rename item
46
47
			if (false === $this->entity->putContents($contents)) return 'FILEMANAGER_ERROR_FILE_EDIT';
48
49
			# ------------------------
50
51
			return true;
52
		}
53
	}
54
}
55