Version20160823215458RemoveKnpMenuTemplate::down()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
 * AnimeDb package.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2011, Peter Gribanov
7
 * @license   http://opensource.org/licenses/GPL-3.0 GPL v3
8
 */
9
10
namespace AnimeDb\Bundle\CatalogBundle\DoctrineMigrations;
11
12
use Doctrine\DBAL\Migrations\AbstractMigration;
13
use Doctrine\DBAL\Schema\Schema;
14
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
15
use Symfony\Component\DependencyInjection\ContainerInterface;
16
use Symfony\Component\Filesystem\Filesystem;
17
18
/**
19
 * Auto-generated Migration: Please modify to your needs!
20
 */
21
class Version20160823215458RemoveKnpMenuTemplate extends AbstractMigration implements ContainerAwareInterface
22
{
23
    /**
24
     * @var Filesystem
25
     */
26
    protected $fs;
27
28
    /**
29
     * @var string
30
     */
31
    protected $tpl;
32
33
    /**
34
     * @param ContainerInterface $container
35
     */
36
    public function setContainer(ContainerInterface $container = null)
37
    {
38
        $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...
39
        $this->tpl = $container->getParameter('kernel.root_dir').'/Resources/knp_menu.html.twig';
40
    }
41
42
    /**
43
     * @param Schema $schema
44
     */
45
    public function up(Schema $schema)
46
    {
47
        $this->fs->remove($this->tpl);
48
    }
49
50
    /**
51
     * @param Schema $schema
52
     */
53
    public function down(Schema $schema)
54
    {
55
        $this->fs->copy(__DIR__.'/data/knp_menu.html.twig', $this->tpl);
56
    }
57
}
58