HookUpdateAllCommand::getConsoleOutPutter()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Created by Graham Owens ([email protected])
4
 * Company: PartFire Ltd (www.partfire.co.uk)
5
 * Console: Relativity
6
 *
7
 * User:    gra
8
 * Date:    16/01/2017
9
 * Time:    23:07
10
 * Project: PartFire MangoPay Bundle
11
 * File:    HookUpdateAllCommand.php
12
 *
13
 **/
14
15
namespace PartFire\MangoPayBundle\Command;
16
17
use Fruitful\IdentityCheckBundle\Entity\IdentityCheck;
18
use Fruitful\IdentityCheckBundle\Entity\Repository\IdentityCheckFactoryRepository;
19
use Fruitful\IdentityCheckBundle\Event\IdentityCheckUpdateEvent;
20
use PartFire\CommonBundle\Services\Output\Cli\ConsoleOutput;
21
use PartFire\MangoPayBundle\Services\Hook;
22
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
23
use Symfony\Component\Console\Input\InputArgument;
24
use Symfony\Component\Console\Input\InputDefinition;
25
use Symfony\Component\Console\Input\InputInterface;
26
use Symfony\Component\Console\Input\InputOption;
27
use Symfony\Component\Console\Output\OutputInterface;
28
use Symfony\Component\EventDispatcher\EventDispatcher;
29
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
30
31
class HookUpdateAllCommand extends ContainerAwareCommand
32
{
33
34
    private $output;
35
36
    protected function configure()
37
    {
38
        $this
39
            ->setName('partfire:mangopay:hook-update-all')
40
            ->setDescription('Update all hook urls')
41
        ;
42
43
    }
44
45
    protected function execute(InputInterface $input, OutputInterface $output)
46
    {
47
        $this->output = $this->getConsoleOutPutter();
48
        $this->output->setOutputer($output);
49
50
        $this->output->info("Listing all hooks with MangoPay");
51
52
        //$url = 'https://stage.fruitful.co/updated';
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...
53
        $url = 'http://138.68.144.130/data-hole.php';
54
55
        $responses = [];
56
57
        $hookItems = $this->getHookService()->list();
58
        foreach($hookItems as $hook) {
59
            $hookId = $hook->Id;
60
            $this->output->infoid("Updating Hook ID " . $hookId . " with " . $url);
61
            try {
62
                $responses[] = $this->getHookService()->update($hookId, $url);
63
            } catch (\Exception $e) {
64
                echo "ERROR - " . $e->getMessage() . "\n";
65
            }
66
        }
67
68
        var_dump($responses);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($responses); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
69
    }
70
71
    private function showTitle($title)
72
    {
73
        $this->output->info(str_pad(" " . $title . " ", 80, "-", STR_PAD_BOTH));
74
    }
75
76
    private function getConsoleOutPutter() : ConsoleOutput
77
    {
78
        return $this->getContainer()->get('partfire_common.output_console');
79
    }
80
81
    private function getHookService() : Hook
82
    {
83
        return $this->getContainer()->get('part_fire_mango_pay.services.hook');
84
    }
85
86
}