Passed
Push — master ( 0f9b88...fa914f )
by Roeland
14:25 queued 12s
created
core/Command/Encryption/Disable.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -28,30 +28,30 @@
 block discarded – undo
28 28
 use Symfony\Component\Console\Output\OutputInterface;
29 29
 
30 30
 class Disable extends Command {
31
-	/** @var IConfig */
32
-	protected $config;
31
+    /** @var IConfig */
32
+    protected $config;
33 33
 
34
-	/**
35
-	 * @param IConfig $config
36
-	 */
37
-	public function __construct(IConfig $config) {
38
-		parent::__construct();
39
-		$this->config = $config;
40
-	}
34
+    /**
35
+     * @param IConfig $config
36
+     */
37
+    public function __construct(IConfig $config) {
38
+        parent::__construct();
39
+        $this->config = $config;
40
+    }
41 41
 
42
-	protected function configure() {
43
-		$this
44
-			->setName('encryption:disable')
45
-			->setDescription('Disable encryption')
46
-		;
47
-	}
42
+    protected function configure() {
43
+        $this
44
+            ->setName('encryption:disable')
45
+            ->setDescription('Disable encryption')
46
+        ;
47
+    }
48 48
 
49
-	protected function execute(InputInterface $input, OutputInterface $output) {
50
-		if ($this->config->getAppValue('core', 'encryption_enabled', 'no') !== 'yes') {
51
-			$output->writeln('Encryption is already disabled');
52
-		} else {
53
-			$this->config->setAppValue('core', 'encryption_enabled', 'no');
54
-			$output->writeln('<info>Encryption disabled</info>');
55
-		}
56
-	}
49
+    protected function execute(InputInterface $input, OutputInterface $output) {
50
+        if ($this->config->getAppValue('core', 'encryption_enabled', 'no') !== 'yes') {
51
+            $output->writeln('Encryption is already disabled');
52
+        } else {
53
+            $this->config->setAppValue('core', 'encryption_enabled', 'no');
54
+            $output->writeln('<info>Encryption disabled</info>');
55
+        }
56
+    }
57 57
 }
Please login to merge, or discard this patch.
core/Command/Encryption/Status.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -28,30 +28,30 @@
 block discarded – undo
28 28
 use Symfony\Component\Console\Output\OutputInterface;
29 29
 
30 30
 class Status extends Base {
31
-	/** @var IManager */
32
-	protected $encryptionManager;
31
+    /** @var IManager */
32
+    protected $encryptionManager;
33 33
 
34
-	/**
35
-	 * @param IManager $encryptionManager
36
-	 */
37
-	public function __construct(IManager $encryptionManager) {
38
-		parent::__construct();
39
-		$this->encryptionManager = $encryptionManager;
40
-	}
34
+    /**
35
+     * @param IManager $encryptionManager
36
+     */
37
+    public function __construct(IManager $encryptionManager) {
38
+        parent::__construct();
39
+        $this->encryptionManager = $encryptionManager;
40
+    }
41 41
 
42
-	protected function configure() {
43
-		parent::configure();
42
+    protected function configure() {
43
+        parent::configure();
44 44
 
45
-		$this
46
-			->setName('encryption:status')
47
-			->setDescription('Lists the current status of encryption')
48
-		;
49
-	}
45
+        $this
46
+            ->setName('encryption:status')
47
+            ->setDescription('Lists the current status of encryption')
48
+        ;
49
+    }
50 50
 
51
-	protected function execute(InputInterface $input, OutputInterface $output) {
52
-		$this->writeArrayInOutputFormat($input, $output, [
53
-			'enabled' => $this->encryptionManager->isEnabled(),
54
-			'defaultModule' => $this->encryptionManager->getDefaultEncryptionModuleId(),
55
-		]);
56
-	}
51
+    protected function execute(InputInterface $input, OutputInterface $output) {
52
+        $this->writeArrayInOutputFormat($input, $output, [
53
+            'enabled' => $this->encryptionManager->isEnabled(),
54
+            'defaultModule' => $this->encryptionManager->getDefaultEncryptionModuleId(),
55
+        ]);
56
+    }
57 57
 }
Please login to merge, or discard this patch.
core/Command/Group/ListCommand.php 2 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -34,58 +34,58 @@
 block discarded – undo
34 34
 use Symfony\Component\Console\Output\OutputInterface;
35 35
 
36 36
 class ListCommand extends Base {
37
-	/** @var IGroupManager */
38
-	protected $groupManager;
37
+    /** @var IGroupManager */
38
+    protected $groupManager;
39 39
 
40
-	/**
41
-	 * @param IGroupManager $groupManager
42
-	 */
43
-	public function __construct(IGroupManager $groupManager) {
44
-		$this->groupManager = $groupManager;
45
-		parent::__construct();
46
-	}
40
+    /**
41
+     * @param IGroupManager $groupManager
42
+     */
43
+    public function __construct(IGroupManager $groupManager) {
44
+        $this->groupManager = $groupManager;
45
+        parent::__construct();
46
+    }
47 47
 
48
-	protected function configure() {
49
-		$this
50
-			->setName('group:list')
51
-			->setDescription('list configured groups')
52
-			->addOption(
53
-				'limit',
54
-				'l',
55
-				InputOption::VALUE_OPTIONAL,
56
-				'Number of groups to retrieve',
57
-				500
58
-			)->addOption(
59
-				'offset',
60
-				'o',
61
-				InputOption::VALUE_OPTIONAL,
62
-				'Offset for retrieving groups',
63
-				0
64
-			)->addOption(
65
-				'output',
66
-				null,
67
-				InputOption::VALUE_OPTIONAL,
68
-				'Output format (plain, json or json_pretty, default is plain)',
69
-				$this->defaultOutputFormat
70
-			);
71
-	}
48
+    protected function configure() {
49
+        $this
50
+            ->setName('group:list')
51
+            ->setDescription('list configured groups')
52
+            ->addOption(
53
+                'limit',
54
+                'l',
55
+                InputOption::VALUE_OPTIONAL,
56
+                'Number of groups to retrieve',
57
+                500
58
+            )->addOption(
59
+                'offset',
60
+                'o',
61
+                InputOption::VALUE_OPTIONAL,
62
+                'Offset for retrieving groups',
63
+                0
64
+            )->addOption(
65
+                'output',
66
+                null,
67
+                InputOption::VALUE_OPTIONAL,
68
+                'Output format (plain, json or json_pretty, default is plain)',
69
+                $this->defaultOutputFormat
70
+            );
71
+    }
72 72
 
73
-	protected function execute(InputInterface $input, OutputInterface $output) {
74
-		$groups = $this->groupManager->search('', (int)$input->getOption('limit'), (int)$input->getOption('offset'));
75
-		$this->writeArrayInOutputFormat($input, $output, $this->formatGroups($groups));
76
-	}
73
+    protected function execute(InputInterface $input, OutputInterface $output) {
74
+        $groups = $this->groupManager->search('', (int)$input->getOption('limit'), (int)$input->getOption('offset'));
75
+        $this->writeArrayInOutputFormat($input, $output, $this->formatGroups($groups));
76
+    }
77 77
 
78
-	/**
79
-	 * @param IGroup[] $groups
80
-	 * @return array
81
-	 */
82
-	private function formatGroups(array $groups) {
83
-		$keys = array_map(function (IGroup $group) {
84
-			return $group->getGID();
85
-		}, $groups);
86
-		$values = array_map(function (IGroup $group) {
87
-			return array_keys($group->getUsers());
88
-		}, $groups);
89
-		return array_combine($keys, $values);
90
-	}
78
+    /**
79
+     * @param IGroup[] $groups
80
+     * @return array
81
+     */
82
+    private function formatGroups(array $groups) {
83
+        $keys = array_map(function (IGroup $group) {
84
+            return $group->getGID();
85
+        }, $groups);
86
+        $values = array_map(function (IGroup $group) {
87
+            return array_keys($group->getUsers());
88
+        }, $groups);
89
+        return array_combine($keys, $values);
90
+    }
91 91
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	}
72 72
 
73 73
 	protected function execute(InputInterface $input, OutputInterface $output) {
74
-		$groups = $this->groupManager->search('', (int)$input->getOption('limit'), (int)$input->getOption('offset'));
74
+		$groups = $this->groupManager->search('', (int) $input->getOption('limit'), (int) $input->getOption('offset'));
75 75
 		$this->writeArrayInOutputFormat($input, $output, $this->formatGroups($groups));
76 76
 	}
77 77
 
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 	 * @return array
81 81
 	 */
82 82
 	private function formatGroups(array $groups) {
83
-		$keys = array_map(function (IGroup $group) {
83
+		$keys = array_map(function(IGroup $group) {
84 84
 			return $group->getGID();
85 85
 		}, $groups);
86
-		$values = array_map(function (IGroup $group) {
86
+		$values = array_map(function(IGroup $group) {
87 87
 			return array_keys($group->getUsers());
88 88
 		}, $groups);
89 89
 		return array_combine($keys, $values);
Please login to merge, or discard this patch.
core/Command/Group/RemoveUser.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -33,47 +33,47 @@
 block discarded – undo
33 33
 use Symfony\Component\Console\Output\OutputInterface;
34 34
 
35 35
 class RemoveUser extends Base {
36
-	/** @var IUserManager */
37
-	protected $userManager;
38
-	/** @var IGroupManager */
39
-	protected $groupManager;
36
+    /** @var IUserManager */
37
+    protected $userManager;
38
+    /** @var IGroupManager */
39
+    protected $groupManager;
40 40
 
41
-	/**
42
-	 * @param IUserManager $userManager
43
-	 * @param IGroupManager $groupManager
44
-	 */
45
-	public function __construct(IUserManager $userManager, IGroupManager $groupManager) {
46
-		$this->userManager = $userManager;
47
-		$this->groupManager = $groupManager;
48
-		parent::__construct();
49
-	}
41
+    /**
42
+     * @param IUserManager $userManager
43
+     * @param IGroupManager $groupManager
44
+     */
45
+    public function __construct(IUserManager $userManager, IGroupManager $groupManager) {
46
+        $this->userManager = $userManager;
47
+        $this->groupManager = $groupManager;
48
+        parent::__construct();
49
+    }
50 50
 
51
-	protected function configure() {
52
-		$this
53
-			->setName('group:removeuser')
54
-			->setDescription('remove a user from a group')
55
-			->addArgument(
56
-				'group',
57
-				InputArgument::REQUIRED,
58
-				'group to remove the user from'
59
-			)->addArgument(
60
-				'user',
61
-				InputArgument::REQUIRED,
62
-				'user to remove from the group'
63
-			);
64
-	}
51
+    protected function configure() {
52
+        $this
53
+            ->setName('group:removeuser')
54
+            ->setDescription('remove a user from a group')
55
+            ->addArgument(
56
+                'group',
57
+                InputArgument::REQUIRED,
58
+                'group to remove the user from'
59
+            )->addArgument(
60
+                'user',
61
+                InputArgument::REQUIRED,
62
+                'user to remove from the group'
63
+            );
64
+    }
65 65
 
66
-	protected function execute(InputInterface $input, OutputInterface $output) {
67
-		$group = $this->groupManager->get($input->getArgument('group'));
68
-		if (is_null($group)) {
69
-			$output->writeln('<error>group not found</error>');
70
-			return 1;
71
-		}
72
-		$user = $this->userManager->get($input->getArgument('user'));
73
-		if (is_null($user)) {
74
-			$output->writeln('<error>user not found</error>');
75
-			return 1;
76
-		}
77
-		$group->removeUser($user);
78
-	}
66
+    protected function execute(InputInterface $input, OutputInterface $output) {
67
+        $group = $this->groupManager->get($input->getArgument('group'));
68
+        if (is_null($group)) {
69
+            $output->writeln('<error>group not found</error>');
70
+            return 1;
71
+        }
72
+        $user = $this->userManager->get($input->getArgument('user'));
73
+        if (is_null($user)) {
74
+            $output->writeln('<error>user not found</error>');
75
+            return 1;
76
+        }
77
+        $group->removeUser($user);
78
+    }
79 79
 }
Please login to merge, or discard this patch.
core/Command/Group/AddUser.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -33,47 +33,47 @@
 block discarded – undo
33 33
 use Symfony\Component\Console\Output\OutputInterface;
34 34
 
35 35
 class AddUser extends Base {
36
-	/** @var IUserManager */
37
-	protected $userManager;
38
-	/** @var IGroupManager */
39
-	protected $groupManager;
36
+    /** @var IUserManager */
37
+    protected $userManager;
38
+    /** @var IGroupManager */
39
+    protected $groupManager;
40 40
 
41
-	/**
42
-	 * @param IUserManager $userManager
43
-	 * @param IGroupManager $groupManager
44
-	 */
45
-	public function __construct(IUserManager $userManager, IGroupManager $groupManager) {
46
-		$this->userManager = $userManager;
47
-		$this->groupManager = $groupManager;
48
-		parent::__construct();
49
-	}
41
+    /**
42
+     * @param IUserManager $userManager
43
+     * @param IGroupManager $groupManager
44
+     */
45
+    public function __construct(IUserManager $userManager, IGroupManager $groupManager) {
46
+        $this->userManager = $userManager;
47
+        $this->groupManager = $groupManager;
48
+        parent::__construct();
49
+    }
50 50
 
51
-	protected function configure() {
52
-		$this
53
-			->setName('group:adduser')
54
-			->setDescription('add a user to a group')
55
-			->addArgument(
56
-				'group',
57
-				InputArgument::REQUIRED,
58
-				'group to add the user to'
59
-			)->addArgument(
60
-				'user',
61
-				InputArgument::REQUIRED,
62
-				'user to add to the group'
63
-			);
64
-	}
51
+    protected function configure() {
52
+        $this
53
+            ->setName('group:adduser')
54
+            ->setDescription('add a user to a group')
55
+            ->addArgument(
56
+                'group',
57
+                InputArgument::REQUIRED,
58
+                'group to add the user to'
59
+            )->addArgument(
60
+                'user',
61
+                InputArgument::REQUIRED,
62
+                'user to add to the group'
63
+            );
64
+    }
65 65
 
66
-	protected function execute(InputInterface $input, OutputInterface $output) {
67
-		$group = $this->groupManager->get($input->getArgument('group'));
68
-		if (is_null($group)) {
69
-			$output->writeln('<error>group not found</error>');
70
-			return 1;
71
-		}
72
-		$user = $this->userManager->get($input->getArgument('user'));
73
-		if (is_null($user)) {
74
-			$output->writeln('<error>user not found</error>');
75
-			return 1;
76
-		}
77
-		$group->addUser($user);
78
-	}
66
+    protected function execute(InputInterface $input, OutputInterface $output) {
67
+        $group = $this->groupManager->get($input->getArgument('group'));
68
+        if (is_null($group)) {
69
+            $output->writeln('<error>group not found</error>');
70
+            return 1;
71
+        }
72
+        $user = $this->userManager->get($input->getArgument('user'));
73
+        if (is_null($user)) {
74
+            $output->writeln('<error>user not found</error>');
75
+            return 1;
76
+        }
77
+        $group->addUser($user);
78
+    }
79 79
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Command/Delete.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
68 68
 		try {
69 69
 			$mount = $this->globalService->getStorage($mountId);
70 70
 		} catch (NotFoundException $e) {
71
-			$output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>');
71
+			$output->writeln('<error>Mount with id "'.$mountId.' not found, check "occ files_external:list" to get available mounts"</error>');
72 72
 			return 404;
73 73
 		}
74 74
 
Please login to merge, or discard this patch.
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -38,76 +38,76 @@
 block discarded – undo
38 38
 use Symfony\Component\Console\Question\ConfirmationQuestion;
39 39
 
40 40
 class Delete extends Base {
41
-	/**
42
-	 * @var GlobalStoragesService
43
-	 */
44
-	protected $globalService;
41
+    /**
42
+     * @var GlobalStoragesService
43
+     */
44
+    protected $globalService;
45 45
 
46
-	/**
47
-	 * @var UserStoragesService
48
-	 */
49
-	protected $userService;
46
+    /**
47
+     * @var UserStoragesService
48
+     */
49
+    protected $userService;
50 50
 
51
-	/**
52
-	 * @var IUserSession
53
-	 */
54
-	protected $userSession;
51
+    /**
52
+     * @var IUserSession
53
+     */
54
+    protected $userSession;
55 55
 
56
-	/**
57
-	 * @var IUserManager
58
-	 */
59
-	protected $userManager;
56
+    /**
57
+     * @var IUserManager
58
+     */
59
+    protected $userManager;
60 60
 
61
-	public function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) {
62
-		parent::__construct();
63
-		$this->globalService = $globalService;
64
-		$this->userService = $userService;
65
-		$this->userSession = $userSession;
66
-		$this->userManager = $userManager;
67
-	}
61
+    public function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) {
62
+        parent::__construct();
63
+        $this->globalService = $globalService;
64
+        $this->userService = $userService;
65
+        $this->userSession = $userSession;
66
+        $this->userManager = $userManager;
67
+    }
68 68
 
69
-	protected function configure() {
70
-		$this
71
-			->setName('files_external:delete')
72
-			->setDescription('Delete an external mount')
73
-			->addArgument(
74
-				'mount_id',
75
-				InputArgument::REQUIRED,
76
-				'The id of the mount to edit'
77
-			)->addOption(
78
-				'yes',
79
-				'y',
80
-				InputOption::VALUE_NONE,
81
-				'Skip confirmation'
82
-			);
83
-		parent::configure();
84
-	}
69
+    protected function configure() {
70
+        $this
71
+            ->setName('files_external:delete')
72
+            ->setDescription('Delete an external mount')
73
+            ->addArgument(
74
+                'mount_id',
75
+                InputArgument::REQUIRED,
76
+                'The id of the mount to edit'
77
+            )->addOption(
78
+                'yes',
79
+                'y',
80
+                InputOption::VALUE_NONE,
81
+                'Skip confirmation'
82
+            );
83
+        parent::configure();
84
+    }
85 85
 
86
-	protected function execute(InputInterface $input, OutputInterface $output) {
87
-		$mountId = $input->getArgument('mount_id');
88
-		try {
89
-			$mount = $this->globalService->getStorage($mountId);
90
-		} catch (NotFoundException $e) {
91
-			$output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>');
92
-			return 404;
93
-		}
86
+    protected function execute(InputInterface $input, OutputInterface $output) {
87
+        $mountId = $input->getArgument('mount_id');
88
+        try {
89
+            $mount = $this->globalService->getStorage($mountId);
90
+        } catch (NotFoundException $e) {
91
+            $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>');
92
+            return 404;
93
+        }
94 94
 
95
-		$noConfirm = $input->getOption('yes');
95
+        $noConfirm = $input->getOption('yes');
96 96
 
97
-		if (!$noConfirm) {
98
-			$listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
99
-			$listInput = new ArrayInput([], $listCommand->getDefinition());
100
-			$listInput->setOption('output', $input->getOption('output'));
101
-			$listCommand->listMounts(null, [$mount], $listInput, $output);
97
+        if (!$noConfirm) {
98
+            $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
99
+            $listInput = new ArrayInput([], $listCommand->getDefinition());
100
+            $listInput->setOption('output', $input->getOption('output'));
101
+            $listCommand->listMounts(null, [$mount], $listInput, $output);
102 102
 
103
-			$questionHelper = $this->getHelper('question');
104
-			$question = new ConfirmationQuestion('Delete this mount? [y/N] ', false);
103
+            $questionHelper = $this->getHelper('question');
104
+            $question = new ConfirmationQuestion('Delete this mount? [y/N] ', false);
105 105
 
106
-			if (!$questionHelper->ask($input, $output, $question)) {
107
-				return null;
108
-			}
109
-		}
106
+            if (!$questionHelper->ask($input, $output, $question)) {
107
+                return null;
108
+            }
109
+        }
110 110
 
111
-		$this->globalService->removeStorage($mountId);
112
-	}
111
+        $this->globalService->removeStorage($mountId);
112
+    }
113 113
 }
Please login to merge, or discard this patch.
core/Command/Config/Import.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 		try {
66 66
 			$configs = $this->validateFileContent($content);
67 67
 		} catch (\UnexpectedValueException $e) {
68
-			$output->writeln('<error>' . $e->getMessage(). '</error>');
68
+			$output->writeln('<error>'.$e->getMessage().'</error>');
69 69
 			return;
70 70
 		}
71 71
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 			}
86 86
 		}
87 87
 
88
-		$output->writeln('<info>Config successfully imported from: ' . $importFile . '</info>');
88
+		$output->writeln('<info>Config successfully imported from: '.$importFile.'</info>');
89 89
 	}
90 90
 
91 91
 	/**
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
 		$additionalKeys = array_diff($arrayKeys, $this->validRootKeys);
140 140
 		$commonKeys = array_intersect($arrayKeys, $this->validRootKeys);
141 141
 		if (!empty($additionalKeys)) {
142
-			throw new \UnexpectedValueException('Found invalid entries in root: ' . implode(', ', $additionalKeys));
142
+			throw new \UnexpectedValueException('Found invalid entries in root: '.implode(', ', $additionalKeys));
143 143
 		}
144 144
 		if (empty($commonKeys)) {
145
-			throw new \UnexpectedValueException('At least one key of the following is expected: ' . implode(', ', $this->validRootKeys));
145
+			throw new \UnexpectedValueException('At least one key of the following is expected: '.implode(', ', $this->validRootKeys));
146 146
 		}
147 147
 
148 148
 		if (isset($array['system'])) {
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	 */
171 171
 	protected function checkTypeRecursively($configValue, $configName) {
172 172
 		if (!is_array($configValue) && !is_bool($configValue) && !is_int($configValue) && !is_string($configValue) && !is_null($configValue)) {
173
-			throw new \UnexpectedValueException('Invalid system config value for "' . $configName . '". Only arrays, bools, integers, strings and null (delete) are allowed.');
173
+			throw new \UnexpectedValueException('Invalid system config value for "'.$configName.'". Only arrays, bools, integers, strings and null (delete) are allowed.');
174 174
 		}
175 175
 		if (is_array($configValue)) {
176 176
 			foreach ($configValue as $key => $value) {
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		foreach ($array as $app => $configs) {
189 189
 			foreach ($configs as $name => $value) {
190 190
 				if (!is_int($value) && !is_string($value) && !is_null($value)) {
191
-					throw new \UnexpectedValueException('Invalid app config value for "' . $app . '":"' . $name . '". Only integers, strings and null (delete) are allowed.');
191
+					throw new \UnexpectedValueException('Invalid app config value for "'.$app.'":"'.$name.'". Only integers, strings and null (delete) are allowed.');
192 192
 				}
193 193
 			}
194 194
 		}
Please login to merge, or discard this patch.
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -34,193 +34,193 @@
 block discarded – undo
34 34
 use Symfony\Component\Console\Output\OutputInterface;
35 35
 
36 36
 class Import extends Command implements CompletionAwareInterface {
37
-	protected $validRootKeys = ['system', 'apps'];
38
-
39
-	/** @var IConfig */
40
-	protected $config;
41
-
42
-	/**
43
-	 * @param IConfig $config
44
-	 */
45
-	public function __construct(IConfig $config) {
46
-		parent::__construct();
47
-		$this->config = $config;
48
-	}
49
-
50
-	protected function configure() {
51
-		$this
52
-			->setName('config:import')
53
-			->setDescription('Import a list of configs')
54
-			->addArgument(
55
-				'file',
56
-				InputArgument::OPTIONAL,
57
-				'File with the json array to import'
58
-			)
59
-		;
60
-	}
61
-
62
-	protected function execute(InputInterface $input, OutputInterface $output) {
63
-		$importFile = $input->getArgument('file');
64
-		if ($importFile !== null) {
65
-			$content = $this->getArrayFromFile($importFile);
66
-		} else {
67
-			$content = $this->getArrayFromStdin();
68
-		}
69
-
70
-		try {
71
-			$configs = $this->validateFileContent($content);
72
-		} catch (\UnexpectedValueException $e) {
73
-			$output->writeln('<error>' . $e->getMessage(). '</error>');
74
-			return;
75
-		}
76
-
77
-		if (!empty($configs['system'])) {
78
-			$this->config->setSystemValues($configs['system']);
79
-		}
80
-
81
-		if (!empty($configs['apps'])) {
82
-			foreach ($configs['apps'] as $app => $appConfigs) {
83
-				foreach ($appConfigs as $key => $value) {
84
-					if ($value === null) {
85
-						$this->config->deleteAppValue($app, $key);
86
-					} else {
87
-						$this->config->setAppValue($app, $key, $value);
88
-					}
89
-				}
90
-			}
91
-		}
92
-
93
-		$output->writeln('<info>Config successfully imported from: ' . $importFile . '</info>');
94
-	}
95
-
96
-	/**
97
-	 * Get the content from stdin ("config:import < file.json")
98
-	 *
99
-	 * @return string
100
-	 */
101
-	protected function getArrayFromStdin() {
102
-		// Read from stdin. stream_set_blocking is used to prevent blocking
103
-		// when nothing is passed via stdin.
104
-		stream_set_blocking(STDIN, 0);
105
-		$content = file_get_contents('php://stdin');
106
-		stream_set_blocking(STDIN, 1);
107
-		return $content;
108
-	}
109
-
110
-	/**
111
-	 * Get the content of the specified file ("config:import file.json")
112
-	 *
113
-	 * @param string $importFile
114
-	 * @return string
115
-	 */
116
-	protected function getArrayFromFile($importFile) {
117
-		return file_get_contents($importFile);
118
-	}
119
-
120
-	/**
121
-	 * @param string $content
122
-	 * @return array
123
-	 * @throws \UnexpectedValueException when the array is invalid
124
-	 */
125
-	protected function validateFileContent($content) {
126
-		$decodedContent = json_decode($content, true);
127
-		if (!is_array($decodedContent) || empty($decodedContent)) {
128
-			throw new \UnexpectedValueException('The file must contain a valid json array');
129
-		}
130
-
131
-		$this->validateArray($decodedContent);
132
-
133
-		return $decodedContent;
134
-	}
135
-
136
-	/**
137
-	 * Validates that the array only contains `system` and `apps`
138
-	 *
139
-	 * @param array $array
140
-	 */
141
-	protected function validateArray($array) {
142
-		$arrayKeys = array_keys($array);
143
-		$additionalKeys = array_diff($arrayKeys, $this->validRootKeys);
144
-		$commonKeys = array_intersect($arrayKeys, $this->validRootKeys);
145
-		if (!empty($additionalKeys)) {
146
-			throw new \UnexpectedValueException('Found invalid entries in root: ' . implode(', ', $additionalKeys));
147
-		}
148
-		if (empty($commonKeys)) {
149
-			throw new \UnexpectedValueException('At least one key of the following is expected: ' . implode(', ', $this->validRootKeys));
150
-		}
151
-
152
-		if (isset($array['system'])) {
153
-			if (is_array($array['system'])) {
154
-				foreach ($array['system'] as $name => $value) {
155
-					$this->checkTypeRecursively($value, $name);
156
-				}
157
-			} else {
158
-				throw new \UnexpectedValueException('The system config array is not an array');
159
-			}
160
-		}
161
-
162
-		if (isset($array['apps'])) {
163
-			if (is_array($array['apps'])) {
164
-				$this->validateAppsArray($array['apps']);
165
-			} else {
166
-				throw new \UnexpectedValueException('The apps config array is not an array');
167
-			}
168
-		}
169
-	}
170
-
171
-	/**
172
-	 * @param mixed $configValue
173
-	 * @param string $configName
174
-	 */
175
-	protected function checkTypeRecursively($configValue, $configName) {
176
-		if (!is_array($configValue) && !is_bool($configValue) && !is_int($configValue) && !is_string($configValue) && !is_null($configValue)) {
177
-			throw new \UnexpectedValueException('Invalid system config value for "' . $configName . '". Only arrays, bools, integers, strings and null (delete) are allowed.');
178
-		}
179
-		if (is_array($configValue)) {
180
-			foreach ($configValue as $key => $value) {
181
-				$this->checkTypeRecursively($value, $configName);
182
-			}
183
-		}
184
-	}
185
-
186
-	/**
187
-	 * Validates that app configs are only integers and strings
188
-	 *
189
-	 * @param array $array
190
-	 */
191
-	protected function validateAppsArray($array) {
192
-		foreach ($array as $app => $configs) {
193
-			foreach ($configs as $name => $value) {
194
-				if (!is_int($value) && !is_string($value) && !is_null($value)) {
195
-					throw new \UnexpectedValueException('Invalid app config value for "' . $app . '":"' . $name . '". Only integers, strings and null (delete) are allowed.');
196
-				}
197
-			}
198
-		}
199
-	}
200
-
201
-	/**
202
-	 * @param string $optionName
203
-	 * @param CompletionContext $context
204
-	 * @return string[]
205
-	 */
206
-	public function completeOptionValues($optionName, CompletionContext $context) {
207
-		return [];
208
-	}
209
-
210
-	/**
211
-	 * @param string $argumentName
212
-	 * @param CompletionContext $context
213
-	 * @return string[]
214
-	 */
215
-	public function completeArgumentValues($argumentName, CompletionContext $context) {
216
-		if ($argumentName === 'file') {
217
-			$helper = new ShellPathCompletion(
218
-				$this->getName(),
219
-				'file',
220
-				Completion::TYPE_ARGUMENT
221
-			);
222
-			return $helper->run();
223
-		}
224
-		return [];
225
-	}
37
+    protected $validRootKeys = ['system', 'apps'];
38
+
39
+    /** @var IConfig */
40
+    protected $config;
41
+
42
+    /**
43
+     * @param IConfig $config
44
+     */
45
+    public function __construct(IConfig $config) {
46
+        parent::__construct();
47
+        $this->config = $config;
48
+    }
49
+
50
+    protected function configure() {
51
+        $this
52
+            ->setName('config:import')
53
+            ->setDescription('Import a list of configs')
54
+            ->addArgument(
55
+                'file',
56
+                InputArgument::OPTIONAL,
57
+                'File with the json array to import'
58
+            )
59
+        ;
60
+    }
61
+
62
+    protected function execute(InputInterface $input, OutputInterface $output) {
63
+        $importFile = $input->getArgument('file');
64
+        if ($importFile !== null) {
65
+            $content = $this->getArrayFromFile($importFile);
66
+        } else {
67
+            $content = $this->getArrayFromStdin();
68
+        }
69
+
70
+        try {
71
+            $configs = $this->validateFileContent($content);
72
+        } catch (\UnexpectedValueException $e) {
73
+            $output->writeln('<error>' . $e->getMessage(). '</error>');
74
+            return;
75
+        }
76
+
77
+        if (!empty($configs['system'])) {
78
+            $this->config->setSystemValues($configs['system']);
79
+        }
80
+
81
+        if (!empty($configs['apps'])) {
82
+            foreach ($configs['apps'] as $app => $appConfigs) {
83
+                foreach ($appConfigs as $key => $value) {
84
+                    if ($value === null) {
85
+                        $this->config->deleteAppValue($app, $key);
86
+                    } else {
87
+                        $this->config->setAppValue($app, $key, $value);
88
+                    }
89
+                }
90
+            }
91
+        }
92
+
93
+        $output->writeln('<info>Config successfully imported from: ' . $importFile . '</info>');
94
+    }
95
+
96
+    /**
97
+     * Get the content from stdin ("config:import < file.json")
98
+     *
99
+     * @return string
100
+     */
101
+    protected function getArrayFromStdin() {
102
+        // Read from stdin. stream_set_blocking is used to prevent blocking
103
+        // when nothing is passed via stdin.
104
+        stream_set_blocking(STDIN, 0);
105
+        $content = file_get_contents('php://stdin');
106
+        stream_set_blocking(STDIN, 1);
107
+        return $content;
108
+    }
109
+
110
+    /**
111
+     * Get the content of the specified file ("config:import file.json")
112
+     *
113
+     * @param string $importFile
114
+     * @return string
115
+     */
116
+    protected function getArrayFromFile($importFile) {
117
+        return file_get_contents($importFile);
118
+    }
119
+
120
+    /**
121
+     * @param string $content
122
+     * @return array
123
+     * @throws \UnexpectedValueException when the array is invalid
124
+     */
125
+    protected function validateFileContent($content) {
126
+        $decodedContent = json_decode($content, true);
127
+        if (!is_array($decodedContent) || empty($decodedContent)) {
128
+            throw new \UnexpectedValueException('The file must contain a valid json array');
129
+        }
130
+
131
+        $this->validateArray($decodedContent);
132
+
133
+        return $decodedContent;
134
+    }
135
+
136
+    /**
137
+     * Validates that the array only contains `system` and `apps`
138
+     *
139
+     * @param array $array
140
+     */
141
+    protected function validateArray($array) {
142
+        $arrayKeys = array_keys($array);
143
+        $additionalKeys = array_diff($arrayKeys, $this->validRootKeys);
144
+        $commonKeys = array_intersect($arrayKeys, $this->validRootKeys);
145
+        if (!empty($additionalKeys)) {
146
+            throw new \UnexpectedValueException('Found invalid entries in root: ' . implode(', ', $additionalKeys));
147
+        }
148
+        if (empty($commonKeys)) {
149
+            throw new \UnexpectedValueException('At least one key of the following is expected: ' . implode(', ', $this->validRootKeys));
150
+        }
151
+
152
+        if (isset($array['system'])) {
153
+            if (is_array($array['system'])) {
154
+                foreach ($array['system'] as $name => $value) {
155
+                    $this->checkTypeRecursively($value, $name);
156
+                }
157
+            } else {
158
+                throw new \UnexpectedValueException('The system config array is not an array');
159
+            }
160
+        }
161
+
162
+        if (isset($array['apps'])) {
163
+            if (is_array($array['apps'])) {
164
+                $this->validateAppsArray($array['apps']);
165
+            } else {
166
+                throw new \UnexpectedValueException('The apps config array is not an array');
167
+            }
168
+        }
169
+    }
170
+
171
+    /**
172
+     * @param mixed $configValue
173
+     * @param string $configName
174
+     */
175
+    protected function checkTypeRecursively($configValue, $configName) {
176
+        if (!is_array($configValue) && !is_bool($configValue) && !is_int($configValue) && !is_string($configValue) && !is_null($configValue)) {
177
+            throw new \UnexpectedValueException('Invalid system config value for "' . $configName . '". Only arrays, bools, integers, strings and null (delete) are allowed.');
178
+        }
179
+        if (is_array($configValue)) {
180
+            foreach ($configValue as $key => $value) {
181
+                $this->checkTypeRecursively($value, $configName);
182
+            }
183
+        }
184
+    }
185
+
186
+    /**
187
+     * Validates that app configs are only integers and strings
188
+     *
189
+     * @param array $array
190
+     */
191
+    protected function validateAppsArray($array) {
192
+        foreach ($array as $app => $configs) {
193
+            foreach ($configs as $name => $value) {
194
+                if (!is_int($value) && !is_string($value) && !is_null($value)) {
195
+                    throw new \UnexpectedValueException('Invalid app config value for "' . $app . '":"' . $name . '". Only integers, strings and null (delete) are allowed.');
196
+                }
197
+            }
198
+        }
199
+    }
200
+
201
+    /**
202
+     * @param string $optionName
203
+     * @param CompletionContext $context
204
+     * @return string[]
205
+     */
206
+    public function completeOptionValues($optionName, CompletionContext $context) {
207
+        return [];
208
+    }
209
+
210
+    /**
211
+     * @param string $argumentName
212
+     * @param CompletionContext $context
213
+     * @return string[]
214
+     */
215
+    public function completeArgumentValues($argumentName, CompletionContext $context) {
216
+        if ($argumentName === 'file') {
217
+            $helper = new ShellPathCompletion(
218
+                $this->getName(),
219
+                'file',
220
+                Completion::TYPE_ARGUMENT
221
+            );
222
+            return $helper->run();
223
+        }
224
+        return [];
225
+    }
226 226
 }
Please login to merge, or discard this patch.
lib/public/Contacts/ContactsMenu/IAction.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -33,33 +33,33 @@
 block discarded – undo
33 33
  */
34 34
 interface IAction extends JsonSerializable {
35 35
 
36
-	/**
37
-	 * @param string $icon absolute URI to an icon
38
-	 * @since 12.0
39
-	 */
40
-	public function setIcon($icon);
36
+    /**
37
+     * @param string $icon absolute URI to an icon
38
+     * @since 12.0
39
+     */
40
+    public function setIcon($icon);
41 41
 
42
-	/**
43
-	 * @return string localized action name, e.g. 'Call'
44
-	 * @since 12.0
45
-	 */
46
-	public function getName();
42
+    /**
43
+     * @return string localized action name, e.g. 'Call'
44
+     * @since 12.0
45
+     */
46
+    public function getName();
47 47
 
48
-	/**
49
-	 * @param string $name localized action name, e.g. 'Call'
50
-	 * @since 12.0
51
-	 */
52
-	public function setName($name);
48
+    /**
49
+     * @param string $name localized action name, e.g. 'Call'
50
+     * @since 12.0
51
+     */
52
+    public function setName($name);
53 53
 
54
-	/**
55
-	 * @param int $priority priorize actions, high order ones are shown on top
56
-	 * @since 12.0
57
-	 */
58
-	public function setPriority($priority);
54
+    /**
55
+     * @param int $priority priorize actions, high order ones are shown on top
56
+     * @since 12.0
57
+     */
58
+    public function setPriority($priority);
59 59
 
60
-	/**
61
-	 * @return int priority to priorize actions, high order ones are shown on top
62
-	 * @since 12.0
63
-	 */
64
-	public function getPriority();
60
+    /**
61
+     * @return int priority to priorize actions, high order ones are shown on top
62
+     * @since 12.0
63
+     */
64
+    public function getPriority();
65 65
 }
Please login to merge, or discard this patch.
lib/public/Contacts/ContactsMenu/IActionFactory.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -28,27 +28,27 @@
 block discarded – undo
28 28
  */
29 29
 interface IActionFactory {
30 30
 
31
-	/**
32
-	 * Construct and return a new link action for the contacts menu
33
-	 *
34
-	 * @since 12.0
35
-	 *
36
-	 * @param string $icon full path to the action's icon
37
-	 * @param string $name localized name of the action
38
-	 * @param string $href target URL
39
-	 * @return ILinkAction
40
-	 */
41
-	public function newLinkAction($icon, $name, $href);
31
+    /**
32
+     * Construct and return a new link action for the contacts menu
33
+     *
34
+     * @since 12.0
35
+     *
36
+     * @param string $icon full path to the action's icon
37
+     * @param string $name localized name of the action
38
+     * @param string $href target URL
39
+     * @return ILinkAction
40
+     */
41
+    public function newLinkAction($icon, $name, $href);
42 42
 
43
-	/**
44
-	 * Construct and return a new email action for the contacts menu
45
-	 *
46
-	 * @since 12.0
47
-	 *
48
-	 * @param string $icon full path to the action's icon
49
-	 * @param string $name localized name of the action
50
-	 * @param string $email target e-mail address
51
-	 * @return ILinkAction
52
-	 */
53
-	public function newEMailAction($icon, $name, $email);
43
+    /**
44
+     * Construct and return a new email action for the contacts menu
45
+     *
46
+     * @since 12.0
47
+     *
48
+     * @param string $icon full path to the action's icon
49
+     * @param string $name localized name of the action
50
+     * @param string $email target e-mail address
51
+     * @return ILinkAction
52
+     */
53
+    public function newEMailAction($icon, $name, $email);
54 54
 }
Please login to merge, or discard this patch.