AbstractStingerFixture   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 3
Bugs 1 Features 2
Metric Value
wmc 8
c 3
b 1
f 2
lcom 1
cbo 4
dl 0
loc 62
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 14 2
A reportMemoryUsage() 0 3 1
import() 0 1 ?
A skipMe() 0 3 1
A getLogger() 0 8 4
1
<?php
2
3
/*
4
 * This file is part of the Stinger Soft Platform package.
5
 *
6
 * (c) Oliver Kotte <[email protected]>
7
 * (c) Florian Meyer <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
namespace StingerSoft\PlatformBundle\DataFixtures;
13
14
use Doctrine\Common\DataFixtures\AbstractFixture;
15
use Doctrine\Common\Persistence\ObjectManager;
16
use Psr\Log\LoggerInterface;
17
use Psr\Log\NullLogger;
18
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
19
20
abstract class AbstractStingerFixture extends AbstractFixture {
21
	
22
	use ContainerAwareTrait;
23
24
	/**
25
	 *
26
	 * @var ObjectManager
27
	 */
28
	protected $manager;
29
30
	/**
31
	 *
32
	 * @var LoggerInterface
33
	 */
34
	private $logger;
35
36
	public final function load(ObjectManager $manager) {
0 ignored issues
show
Coding Style introduced by
As per PSR2, final should precede the visibility keyword.
Loading history...
37
		$this->manager = $manager;
38
		if(!$this->skipMe()) {
39
			$this->getLogger()->info("Starting import of fixtures ...");
40
			$this->reportMemoryUsage();
41
			// $startTime = microtime(true);
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
42
			$this->import();
43
			// $endTime = microtime(true);
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
44
			// $this->info("Finished importing fixtures in " . $this->formatTime($startTime, $endTime));
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
45
			$this->reportMemoryUsage();
46
		} else {
47
			$this->getLogger()->info('Skipping import of fixtures !');
48
		}
49
	}
50
51
	protected final function reportMemoryUsage() {
0 ignored issues
show
Coding Style introduced by
As per PSR2, final should precede the visibility keyword.
Loading history...
52
		// $this->getLogger()->info("Currently using %s of RAM", $this->getMemoryUsage());
0 ignored issues
show
Unused Code Comprehensibility introduced by
74% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
53
	}
54
55
	/**
56
	 * Load data fixtures
57
	 */
58
	protected abstract function import();
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
59
60
	/**
61
	 * Decides whether this fixture should be skipped or not.
62
	 *
63
	 * @return bool
64
	 */
65
	protected function skipMe() {
66
		return false;
67
	}
68
69
	/**
70
	 *
71
	 * @return LoggerInterface|null
0 ignored issues
show
Documentation introduced by
Should the return type not be object?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
72
	 */
73
	protected function getLogger() {
74
		if(!$this->logger && $this->container && $this->container->has('logger')) {
75
			$this->logger = $this->container->get('logger');
76
		} else {
77
			$this->logger = new NullLogger();
78
		}
79
		return $this->logger;
80
	}
81
}