Client::extractContent()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 2
1
<?php declare(strict_types=1);
2
3
namespace Goose;
4
5
/**
6
 * Client
7
 *
8
 * @package Goose
9
 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
10
 */
11
class Client {
12
    /** @var Configuration */
13
    protected $config;
14
15
    /**
16
     * @param mixed[] $config
17
     */
18
    public function __construct($config = []) {
19
        $this->config = new Configuration($config);
20
    }
21
22
    /**
23
     * @param string $name
24
     * @param mixed[] $arguments
25
     *
26
     * @return mixed
27
     */
28
    public function __call(string $name, $arguments) {
29
        if (method_exists($this->config, $name)) {
30
            return call_user_func_array(array($this->config, $name), $arguments);
31
        }
32
33
        return null;
34
    }
35
36
    /**
37
     * @param string $url
38
     * @param string $rawHTML
39
     *
40
     * @return Article
41
     */
42
    public function extractContent(string $url, string $rawHTML = null): ?Article {
43
        $crawler = new Crawler($this->config);
44
        $article = $crawler->crawl($url, $rawHTML);
45
46
        return $article;
47
    }
48
}