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

SeedCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 4 1
A command() 0 19 3
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
}