Passed
Push — master ( f13f78...5c1b24 )
by Ismayil
04:22
created

SeedCommand::command()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 10
nc 3
nop 0
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Elgg\Cli;
4
5
/**
6
 * elgg-cli seed
7
 */
8
class SeedCommand extends Command {
9
10
	/**
11
	 * {@inheritdoc}
12
	 */
13
	protected function configure() {
14
		$this->setName('seed')
15
			->setDescription('Seeds the database with fake entities');
16
	}
17
18
	/**
19
	 * {@inheritdoc}
20
	 */
21
	protected function command() {
22
23
24
		if (!class_exists('\Faker\Generator')) {
25
			elgg_log('This is a developer tool currently intended for testing purposes only. Please refrain from using it.', 'ERROR');
26
			return 1;
27
		}
28
		
29
		set_time_limit(0);
30
31
		if (elgg_is_logged_in()) {
32
			elgg_log("Seeds should not be run with a logged in user", 'ERROR');
33
			return 2;
34
		}
35
36
		_elgg_services()->setValue('mailer', new \Zend\Mail\Transport\InMemory());
37
38
		_elgg_services()->seeder->seed();
39
	}
40
41
}