Completed
Push — master ( e5b2f0...e9a020 )
by Florian
02:29
created

AbstractStingerFixture::skipMe()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
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\DataFixtures\DependentFixtureInterface;
16
use Doctrine\Common\Persistence\ObjectManager;
17
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
18
use Psr\Log\LoggerInterface;
19
use Psr\Log\NullLogger;
20
21
abstract class AbstractStingerFixture extends AbstractFixture implements DependentFixtureInterface {
22
	
23
	use ContainerAwareTrait;
24
25
	/**
26
	 *
27
	 * @var ObjectManager
28
	 */
29
	protected $manager;
30
31
	/**
32
	 *
33
	 * @var LoggerInterface
34
	 */
35
	private $logger;
36
37
	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...
38
		$this->manager = $manager;
39
		if(!$this->skipMe()) {
40
			$this->info("Starting import of fixtures ...");
0 ignored issues
show
Bug introduced by
The method info() does not seem to exist on object<StingerSoft\Platf...AbstractStingerFixture>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
41
			$this->reportMemoryUsage();
42
// 			$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...
43
			$this->import();
44
// 			$endTime = microtime(true);
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% 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->info("Finished importing fixtures in " . $this->formatTime($startTime, $endTime));
46
			$this->reportMemoryUsage();
47
		} else {
48
			$this->info('Skipping import of fixtures !');
0 ignored issues
show
Bug introduced by
The method info() does not seem to exist on object<StingerSoft\Platf...AbstractStingerFixture>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
49
		}
50
	}
51
52
	protected final function reportMemoryUsage() {
0 ignored issues
show
Coding Style introduced by
As per PSR2, final should precede the visibility keyword.
Loading history...
53
		$this->info("Currently using %s of RAM", $this->getMemoryUsage());
0 ignored issues
show
Bug introduced by
The method getMemoryUsage() does not seem to exist on object<StingerSoft\Platf...AbstractStingerFixture>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method info() does not seem to exist on object<StingerSoft\Platf...AbstractStingerFixture>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
54
	}
55
56
	/**
57
	 * Load data fixtures
58
	 */
59
	protected abstract function import();
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
60
61
	/**
62
	 * Decides whether this fixture should be skipped or not.
63
	 *
64
	 * @return bool
65
	 */
66
	protected function skipMe() {
67
		return false;
68
	}
69
	
70
71
	/**
72
	 *
73
	 * @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...
74
	 */
75
	protected function getLogger() {
76
		if(!$this->logger && $this->container && $this->container->has('logger')) {
77
			$this->logger = $this->container->get('logger');
78
		} else {
79
			$this->logger = new NullLogger();
80
		}
81
		return $this->logger;
82
	}
83
84
	/**
85
	 */
86
	protected function getDependencies() {
87
	}
88
}