Completed
Push — 0.4.27 ( 854827...eb59a8 )
by Peter
03:11
created

setContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Application\Migrations;
4
5
use Doctrine\DBAL\Migrations\AbstractMigration;
6
use Doctrine\DBAL\Schema\Schema;
7
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8
use Symfony\Component\DependencyInjection\ContainerInterface;
9
use Symfony\Component\Filesystem\Filesystem;
10
11
/**
12
 * Auto-generated Migration: Please modify to your needs!
13
 */
14
class Version20160823215458RemoveKnpMenuTemplate extends AbstractMigration implements ContainerAwareInterface
15
{
16
    /**
17
     * @var Filesystem
18
     */
19
    protected $fs;
20
21
    /**
22
     * @var string
23
     */
24
    protected $tpl;
25
26
    /**
27
     * @param ContainerInterface $container
28
     */
29
    public function setContainer(ContainerInterface $container = null)
30
    {
31
        $this->fs = $container->get('filesystem');
0 ignored issues
show
Bug introduced by
It seems like $container is not always an object, but can also be of type null. Maybe add an additional type check?

If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe:

function someFunction(A $objectMaybe = null)
{
    if ($objectMaybe instanceof A) {
        $objectMaybe->doSomething();
    }
}
Loading history...
32
        $this->tpl = $container->getParameter('kernel.root_dir').'/Resources/knp_menu.html.twig';
33
    }
34
35
    /**
36
     * @param Schema $schema
37
     */
38
    public function up(Schema $schema)
39
    {
40
        $this->fs->remove($this->tpl);
41
    }
42
43
    /**
44
     * @param Schema $schema
45
     */
46
    public function down(Schema $schema)
47
    {
48
        $this->fs->copy(__DIR__ . '/data/knp_menu.html.twig', $this->tpl);
49
    }
50
}
51