RequestTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 41
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fetch() 0 7 1
A setRequestCA() 0 5 1
1
<?php
2
/**
3
 * Trait RequestTrait
4
 *
5
 * @filesource   RequestTrait.php
6
 * @created      13.02.2016
7
 * @package      chillerlan\TinyCurl
8
 * @author       Smiley <[email protected]>
9
 * @copyright    2016 Smiley
10
 * @license      MIT
11
 */
12
13
namespace chillerlan\TinyCurl;
14
15
trait RequestTrait{
16
17
	/**
18
	 * Path to the CA cert file
19
	 *
20
	 * @link http://init.haxx.se/ca/cacert.pem
21
	 * @var string
22
	 */
23
	protected $ca_info;
24
25
	/**
26
	 * Embed stuff from anywhere!
27
	 *
28
	 * @param string $url
29
	 * @param array  $params
30
	 * @param array  $curl_options
31
	 *
32
	 * @return \chillerlan\TinyCurl\ResponseInterface
33
	 */
34
	protected function fetch($url, array $params = [], array $curl_options = []){
35
		$requestOptions               = new RequestOptions;
36
		$requestOptions->curl_options = $curl_options;
37
		$requestOptions->ca_info      = $this->ca_info;
38
39
		return (new Request($requestOptions))->fetch(new URL($url, $params));
40
	}
41
42
	/**
43
	 * Sets the path to the CA cert file
44
	 *
45
	 * @param $ca_info
46
	 *
47
	 * @return $this
48
	 */
49
	protected function setRequestCA($ca_info){
50
		$this->ca_info = $ca_info;
51
52
		return $this;
53
	}
54
55
}
56