BlutMagieParser::parse()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 12

Duplication

Lines 11
Ratio 64.71 %

Code Coverage

Tests 14
CRAP Score 2

Importance

Changes 0
Metric Value
dl 11
loc 17
ccs 14
cts 14
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 12
nc 2
nop 1
crap 2
1
<?php
2
3
namespace BramR\TorExits\Parser;
4
5
use BramR\TorExits\IpList;
6
use Psr\Http\Message\StreamInterface;
7
8
/**
9
 * Class BlutMagieParser
10
 */
11
class BlutMagieParser extends BaseParser
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16 2
    public function parse(StreamInterface $data = null)
17
    {
18 2
        $ips = explode("\n", $this->getStreamData($data)->getContents());
19 2
        $ips = array_filter($ips, 'ip2long');
20 2 View Code Duplication
        if (count($ips) < $this->getParseWarningThreshold()) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21 1
            $this->logger->warning(
22 1
                'Number of Tor exit nodes found when parsing is low.',
23 1
                ['exit-node-count' => count($ips)]
24 1
            );
25 1
        } else {
26 1
            $this->logger->info(
27 1
                'Tor exit nodes parsed from blutmagie.de',
28 1
                ['exit-node-count' => count($ips)]
29 1
            );
30
        }
31 2
        return new IpList($ips);
32
    }
33
}
34