1 | <?php |
||
9 | class PreviewBuilder |
||
10 | { |
||
11 | /** |
||
12 | * @var Crawler |
||
13 | */ |
||
14 | private $crawler; |
||
15 | |||
16 | /** |
||
17 | * @var Cache |
||
18 | */ |
||
19 | private $cache; |
||
20 | |||
21 | /** |
||
22 | * Url object |
||
23 | * @var Url |
||
24 | */ |
||
25 | private $url; |
||
26 | |||
27 | /** |
||
28 | * @var HttpInterface |
||
29 | */ |
||
30 | protected $http; |
||
31 | |||
32 | |||
33 | 90 | public function __construct(HttpInterface $http, CacheItemPoolInterface $cache = null) |
|
40 | |||
41 | /** |
||
42 | * Instantiate class with dependencies |
||
43 | * @param CacheItemPoolInterface $cache |
||
44 | * @return static |
||
45 | */ |
||
46 | 6 | public static function create(CacheItemPoolInterface $cache = null) |
|
51 | |||
52 | /** |
||
53 | * @param string $url |
||
54 | * @return Preview |
||
55 | * @throws \Exception |
||
56 | */ |
||
57 | 51 | public function fetch($url = null) |
|
81 | |||
82 | 3 | public function findUrl($text) |
|
88 | |||
89 | 6 | public function findOrFetch($url) |
|
97 | |||
98 | 3 | public function cache(Preview $preview) |
|
102 | /** |
||
103 | * returns an instance of Preview |
||
104 | * @return Preview |
||
105 | */ |
||
106 | 45 | private function getPreview() |
|
132 | |||
133 | 45 | private function images() |
|
142 | } |
||
143 |