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

RequestFactory::newFromParams()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
rs 10
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