Passed
Push — master ( 1d252d...bd204f )
by Daimona
01:55
created

RequestFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A newFromParams() 0 7 2
A __construct() 0 2 1
1
<?php declare( strict_types=1 );
2
3
namespace BotRiconferme\Request;
4
5
class RequestFactory {
6
	/** @var string */
7
	private $domain;
8
9
	/**
10
	 * @param string $domain
11
	 */
12
	public function __construct( string $domain ) {
13
		$this->domain = $domain;
14
	}
15
16
	/**
17
	 * @param array $params
18
	 * @return RequestBase
19
	 */
20
	public function newFromParams( array $params ) : RequestBase {
21
		if ( extension_loaded( 'curl' ) ) {
22
			$ret = new CurlRequest( $params, $this->domain );
23
		} else {
24
			$ret = new NativeRequest( $params, $this->domain );
25
		}
26
		return $ret;
27
	}
28
}
29