Added support for default options to be passed to the constructor
* Default options are applied to calls to parse(), rels(), feeds() and process()
* Default options are overridden by options passed to the respective function call on a
property-by-property basis
* Documented in README with example
* Added basic test (only for parse() behaviour)
* Also fixed a bug causing an error processing h-cards with no URL property
$this->http=newHTTP('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36 p3k/XRay');
if(is_array($options)){
$this->defaultOptions=$options;
}
}
publicfunctionrels($url,$opts=[]){
$rels=newXRay\Rels($this->http);
// Merge provided options with default options, allowing provided options to override defaults.
$opts=array_merge($this->defaultOptions,$opts);
return$rels->parse($url,$opts);
}
publicfunctionfeeds($url,$opts=[]){
$feeds=newXRay\Feeds($this->http);
// Merge provided options with default options, allowing provided options to override defaults.
$opts=array_merge($this->defaultOptions,$opts);
return$feeds->find($url,$opts);
}
@ -35,6 +44,9 @@ class XRay {
}
$parser=newXRay\Parser($this->http);
// Merge provided options with default options, allowing provided options to override defaults.
$opts=array_merge($this->defaultOptions,$opts);
$result=$parser->parse([
'body'=>$body,
'url'=>$url,
@ -51,6 +63,8 @@ class XRay {
publicfunctionprocess($url,$mf2json,$opts=[]){
$parser=newXRay\Parser($this->http);
// Merge provided options with default options, allowing provided options to override defaults.