Completed
Push — master ( 2c5ba7...319d3c )
by Ivan
04:32
created

CrawlerSession::getUri()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace SP\Spiderling;
4
5
use Psr\Http\Message\UriInterface;
6
use GuzzleHttp\Psr7\Uri;
7
8
/**
9
 * @author    Ivan Kerin <[email protected]>
10
 * @copyright 2015, Clippings Ltd.
11
 * @license   http://spdx.org/licenses/BSD-3-Clause
12
 */
13
class CrawlerSession
14
{
15
    use TraverseTrait;
16
17
    /**
18
     * CrawlerInterface
19
     */
20
    private $crawler;
21
22
    /**
23
     * @param CrawlerInterface $crawler
24
     */
25 1
    public function __construct(CrawlerInterface $crawler)
26
    {
27 1
        $this->crawler = $crawler;
28 1
    }
29
30
    /**
31
     * @param  Query\AbstractQuery $query
32
     * @return array
33
     */
34 1
    public function queryIds(Query\AbstractQuery $query)
35
    {
36 1
        return $this->crawler->queryIds($query);
37
    }
38
39
    /**
40
     * @return CrawlerInterface
41
     */
42 1
    public function getCrawler()
43
    {
44 1
        return $this->crawler;
45
    }
46
47
    /**
48
     * @param  string $uri
49
     * @return self
50
     */
51 1
    public function open($uri)
52
    {
53 1
        if (false === ($uri instanceof UriInterface)) {
54 1
            $uri = new Uri($uri);
55 1
        }
56
57 1
        $this->crawler->open($uri);
58
59 1
        return $this;
60
    }
61
62
    /**
63
     * @return UriInterface
64
     */
65 1
    public function getUri()
66
    {
67 1
        return $this->crawler->getUri();
68
    }
69
70
    /**
71
     * @return string
72
     */
73 1
    public function getHtml()
74
    {
75 1
        return $this->crawler->getFullHtml();
76
    }
77
}
78