Browse Source

Applied default options to fetch call as well as parser processing

pull/113/head
Barnaby Walters 1 year ago
parent
commit
2886b9f339
2 changed files with 6 additions and 2 deletions
  1. +6
    -1
      lib/XRay.php
  2. +0
    -1
      tests/LibraryTest.php

+ 6
- 1
lib/XRay.php View File

@ -30,7 +30,12 @@ class XRay {
public function parse($url, $opts_or_body=false, $opts_for_body=[]) {
if(!$opts_or_body || is_array($opts_or_body)) {
$fetch = new XRay\Fetcher($this->http);
$response = $fetch->fetch($url, $opts_or_body);
if (is_array($opts_or_body)) {
$fetch_opts = array_merge($this->defaultOptions, $opts_or_body);
} else {
$fetch_opts = $this->defaultOptions;
}
$response = $fetch->fetch($url, $fetch_opts);
if(!empty($response['error']))
return $response;
$body = $response['body'];

+ 0
- 1
tests/LibraryTest.php View File

@ -108,5 +108,4 @@ class LibraryTest extends PHPUnit\Framework\TestCase
$normalXRay->parse($url, $html)
);
}
}

Loading…
Cancel
Save