Completed
Push — master ( b1fcd8...e7aa16 )
by Nikolai
04:26 queued 01:42
created

Package::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
crap 1
1
<?php
2
/**
3
 * Crowdin API implementation in PHP.
4
 *
5
 * @copyright  Copyright (C) 2016 Nikolai Plath (elkuku)
6
 * @license    GNU General Public License version 2 or later
7
 */
8
9
namespace ElKuKu\Crowdin;
10
11
use GuzzleHttp\Client as HttpClient;
12
13
/**
14
 * Class Package
15
 *
16
 * @since  1.0
17
 */
18
abstract class Package
19
{
20
	/**
21
	 * The Crowdin project id.
22
	 * @var string
23
	 */
24
	private $projectId;
25
26
	/**
27
	 * The Crowdin API key.
28
	 * @var string
29
	 */
30
	private $apiKey;
31
32
	/**
33
	 * The HTTP client object.
34
	 * @var HttpClient
35
	 */
36
	private $httpClient;
37
38
	/**
39
	 * Constructor.
40
	 *
41
	 * @param   string      $projectId   The project ID.
42
	 * @param   string      $apiKey      The API key
43
	 * @param   HttpClient  $httpClient  The HTTP client object.
44
	 */
45 1
	public function __construct($projectId, $apiKey, HttpClient $httpClient)
46
	{
47 1
		$this->projectId  = $projectId;
48 1
		$this->apiKey     = $apiKey;
49 1
		$this->httpClient = $httpClient;
50 1
	}
51
52
	/**
53
	 * Get the project ID.
54
	 *
55
	 * @return string
56
	 */
57 1
	protected function getProjectId()
58
	{
59 1
		return $this->projectId;
60
	}
61
62
	/**
63
	 * Get the API key.
64
	 *
65
	 * @return string
66
	 */
67 1
	protected function getApiKey()
68
	{
69 1
		return $this->apiKey;
70
	}
71
72
	/**
73
	 * Get the HTTP client object.
74
	 *
75
	 * @return HttpClient
76
	 */
77 1
	protected function getHttpClient()
78
	{
79 1
		return $this->httpClient;
80
	}
81
82
	/**
83
	 * Get the base path for the command including an action.
84
	 *
85
	 * @param   string  $action  The action to perform.
86
	 *
87
	 * @return string
88
	 */
89 1
	protected function getBasePath($action)
90
	{
91 1
		return sprintf(
92 1
			'project/%s/%s?key=%s',
93 1
			$this->getProjectId(),
94
			$action,
95 1
			$this->getApiKey()
96
		);
97
	}
98
}
99