Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
9 / 9
BaseCommand
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
9 / 9
 configure
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
4 / 4
 initialize
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
5 / 5
1<?php
2
3namespace AlexisLefebvre\Bundle\AsyncTweetsBundle\Command;
4
5use Doctrine\Persistence\ObjectManager;
6use Symfony\Bridge\Doctrine\ManagerRegistry;
7use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
8use Symfony\Component\Console\Input\InputInterface;
9use Symfony\Component\Console\Output\OutputInterface;
10use Symfony\Component\DependencyInjection\ContainerInterface;
11
12class BaseCommand extends ContainerAwareCommand
13{
14    /** @var ContainerInterface */
15    protected $container;
16    /** @var ObjectManager */
17    protected $em;
18
19    protected function configure(): void
20    {
21        parent::configure();
22
23        $this
24            ->setName('statuses:base')
25            ->setDescription('Base command');
26    }
27
28    protected function initialize(InputInterface $input, OutputInterface $output): void
29    {
30        parent::initialize($input, $output); //initialize parent class method
31
32        $this->container = $this->getContainer();
33
34        // This loads Doctrine, you can load your own services as well
35        /** @var ManagerRegistry $doctrine */
36        $doctrine = $this->container->get('doctrine');
37        $this->em = $doctrine->getManager();
38    }
39}