Passed
Pull Request — master (#3)
by Vincent
08:42
created

TestEntityMapper::buildFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
use Bdf\Prime\Entity\InitializableInterface;
4
use Bdf\Prime\Entity\Model;
5
use Bdf\Prime\Mapper\Mapper;
6
use Bdf\Prime\Query\Custom\KeyValue\KeyValueQuery;
7
use Bdf\Prime\Repository\EntityRepository;
8
use Bdf\Prime\TestEmbeddedEntity;
9
use Symfony\Component\Config\Loader\LoaderInterface;
10
use Symfony\Component\DependencyInjection\ContainerBuilder;
11
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
12
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
13
use Symfony\Component\Routing\RouteCollectionBuilder;
14
15
class TestKernel extends \Symfony\Component\HttpKernel\Kernel
16
{
17
    use \Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
0 ignored issues
show
Bug introduced by
The trait Symfony\Bundle\Framework...Kernel\MicroKernelTrait requires the property $instanceof which is not provided by TestKernel.
Loading history...
18
19
    public function registerBundles(): iterable
20
    {
21
        return [
22
            new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
23
            new \Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(),
24
            new \Symfony\Bundle\TwigBundle\TwigBundle(),
25
            new \Bdf\PrimeBundle\PrimeBundle(),
26
            new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
27
        ];
28
    }
29
30
    protected function configureRoutes($routes)
31
    {
32
        //$routes->add('index', '/')->controller([$this, 'indexAction']);
33
        if ($routes instanceof RouteCollectionBuilder) {
34
            $routes->add('/', 'kernel::indexAction');
35
            $routes->import('@WebProfilerBundle/Resources/config/routing/wdt.xml', '/_wdt');
36
            $routes->import('@WebProfilerBundle/Resources/config/routing/profiler.xml', '/_profiler');
37
        } else {
38
            $routes->add('index', '/')->controller([$this, 'indexAction']);
39
            $routes->import('@WebProfilerBundle/Resources/config/routing/wdt.xml');
40
            $routes->import('@WebProfilerBundle/Resources/config/routing/profiler.xml');
41
        }
42
    }
43
44
    protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

44
    protected function configureContainer(/** @scrutinizer ignore-unused */ ContainerBuilder $c, LoaderInterface $loader)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
45
    {
46
        $loader->load(__DIR__.'/conf.yaml');
47
        //$c->import(__DIR__.'/conf.yaml');
48
    }
49
50
    public function indexAction()
51
    {
52
        TestEntity::repository()->schema()->migrate();
53
        TestEntity::findById(5);
0 ignored issues
show
Bug introduced by
The method findById() does not exist on TestEntity. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

53
        TestEntity::/** @scrutinizer ignore-call */ 
54
                    findById(5);
Loading history...
54
55
        return new \Symfony\Component\HttpFoundation\Response(<<<HTML
56
<!DOCTYPE html>
57
<html>
58
    <body>Hello World !</body>
59
</html>
60
HTML
61
);
62
    }
63
}
64
65
66
class TestEntity extends Model
67
{
68
    public $id;
69
    public $name;
70
    public $dateInsert;
71
    public $parentId;
72
    public $parent;
73
74
    public function __construct(array $attributes = [])
75
    {
76
        $this->import($attributes);
77
    }
78
}
79
80
class TestEntityMapper extends Mapper
81
{
82
    /**
83
     * {@inheritdoc}
84
     */
85
    public function schema()
86
    {
87
        return [
88
            'connection' => 'test',
89
            'database' => 'test',
90
            'table' => 'test_',
91
        ];
92
    }
93
94
    /**
95
     * {@inheritdoc}
96
     */
97
    public function buildFields($builder)
98
    {
99
        $builder
100
            ->integer('id')->autoincrement()
101
            ->string('name')
102
            ->datetime('dateInsert')->alias('date_insert')->nillable()
103
        ;
104
    }
105
}
106