GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

SampleIpnListener   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 45
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A onPayboxIpnResponse() 0 15 3
1
<?php
2
3
namespace Lexik\Bundle\PayboxBundle\Listener;
4
5
use Lexik\Bundle\PayboxBundle\Event\PayboxResponseEvent;
6
use Symfony\Component\Filesystem\Filesystem;
7
8
/**
9
 * Sample listener that create a file for each ipn call.
10
 *
11
 * @author Olivier Maisonneuve <[email protected]>
12
 */
13
class SampleIpnListener
14
{
15
    /**
16
     * @var string
17
     */
18
    private $rootDir;
19
20
    /**
21
     * @var Filesystem
22
     */
23
    private $filesystem;
24
25
    /**
26
     * Constructor.
27
     *
28
     * @param string     $rootDir
29
     * @param Filesystem $filesystem
30
     */
31
    public function __construct($rootDir, Filesystem $filesystem)
32
    {
33
        $this->rootDir = $rootDir;
34
        $this->filesystem = $filesystem;
35
    }
36
37
    /**
38
     * Creates a txt file containing all parameters for each IPN.
39
     *
40
     * @param PayboxResponseEvent $event
41
     */
42
    public function onPayboxIpnResponse(PayboxResponseEvent $event)
43
    {
44
        $path = sprintf('%s/../data/%s', $this->rootDir, date('Y\/m\/d\/'));
45
        $this->filesystem->mkdir($path);
46
47
        $content = sprintf('Signature verification : %s%s', $event->isVerified() ? 'OK' : 'KO', PHP_EOL);
48
        foreach ($event->getData() as $key => $value) {
49
            $content .= sprintf("%s:%s%s", $key, $value, PHP_EOL);
50
        }
51
52
        file_put_contents(
53
            sprintf('%s%s.txt', $path, time()),
54
            $content
55
        );
56
    }
57
}
58