Passed
Push — master ( e52ce1...eef7fd )
by Ryan
13:31
created

sandbox.php (2 issues)

Labels
1
#! /usr/bin/env php
2
<?php
3
require_once __DIR__ . '/vendor/autoload.php';
4
5
use GuzzleHttp\Psr7;
6
use Monolog\Handler\ErrorLogHandler;
7
use Monolog\Logger;
8
use Psr\Log\LogLevel;
9
use SimplePie\Configuration;
10
use SimplePie\Container;
0 ignored issues
show
The type SimplePie\Container was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use SimplePie\Enum\DateFormat;
12
use SimplePie\HandlerStack;
13
use SimplePie\Middleware\Xml\Atom;
14
use SimplePie\SimplePie;
15
16
//------------------------------------------------------------------------------
17
18
$logger = new Logger('SimplePie');
19
$logger->pushHandler(new ErrorLogHandler(
20
    ErrorLogHandler::OPERATING_SYSTEM,
21
    LogLevel::DEBUG,
0 ignored issues
show
Psr\Log\LogLevel::DEBUG of type string is incompatible with the type integer expected by parameter $level of Monolog\Handler\ErrorLogHandler::__construct(). ( Ignorable by Annotation )

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

21
    /** @scrutinizer ignore-type */ LogLevel::DEBUG,
Loading history...
22
    true,
23
    false
24
));
25
26
$middleware = (new HandlerStack())
27
    ->append(new Atom(), 'atom')
28
;
29
30
$simplepie = (new SimplePie())
31
    ->setLogger($logger)
32
    ->setMiddlewareStack($middleware)
33
;
34
35
//------------------------------------------------------------------------------
36
37
$stream = Psr7\stream_for(file_get_contents(__DIR__ . '/tests/Integration/feeds/test.atom'));
38
$parser = $simplepie->parseXml($stream, true);
39
40
$feed = $parser->getFeed();
41
42
echo '--------------------------------------------------------------------------' . PHP_EOL;
43
44
echo 'count(feed->getLinks): ' . count($feed->getLinks()) . PHP_EOL;
45
echo PHP_EOL;
46
47
$count = 1;
48
foreach ($feed->getLinks() as $link) {
49
    echo sprintf('Link #%d', $count) . PHP_EOL;
50
    echo 'link->getUrl: ' . $link->getUrl() . PHP_EOL;
51
    echo 'link->getRelationship: ' . $link->getRelationship() . PHP_EOL;
52
    echo 'link->getMediaType: ' . $link->getMediaType() . PHP_EOL;
53
    echo 'link->getLanguage: ' . $link->getLanguage() . PHP_EOL;
54
    echo 'link->getTitle: ' . $link->getTitle() . PHP_EOL;
55
    echo 'link->getLength: ' . $link->getLength() . PHP_EOL;
56
57
    echo PHP_EOL;
58
    $count++;
59
}
60
61
print_r(
62
    array_values(
63
        array_filter($feed->getLinks(), function ($l): bool {
64
            return 'self' === $l->getRelationship()->getValue();
65
        })
66
    )
67
);
68
69
echo '--------------------------------------------------------------------------' . PHP_EOL;
70
71
// print_r($feed->getRoot());
72
echo PHP_EOL;
73