Completed
Push — master ( 80f49c...9c7829 )
by Nikolai
02:15
created

Package::getBasePath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 6
nc 1
nop 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
	 * @var string
22
	 */
23
	private $projectId;
24
25
	/**
26
	 * @var string
27
	 */
28
	private $apiKey;
29
30
	/**
31
	 * @var HttpClient
32
	 */
33
	private $httpClient;
34
35
	/**
36
	 * Constructor.
37
	 *
38
	 * @param   string      $projectId   The project ID.
39
	 * @param   string      $apiKey      The API key
40
	 * @param   HttpClient  $httpClient  The HTTP client object.
41
	 */
42
	public function __construct($projectId, $apiKey, HttpClient $httpClient)
43
	{
44
		$this->projectId  = $projectId;
45
		$this->apiKey     = $apiKey;
46
		$this->httpClient = $httpClient;
47
	}
48
49
	/**
50
	 * Get the project ID.
51
	 *
52
	 * @return string
53
	 */
54
	protected function getProjectId()
55
	{
56
		return $this->projectId;
57
	}
58
59
	/**
60
	 * Get the API key.
61
	 *
62
	 * @return string
63
	 */
64
	protected function getApiKey()
65
	{
66
		return $this->apiKey;
67
	}
68
69
	/**
70
	 * Get the HTTP client object.
71
	 *
72
	 * @return HttpClient
73
	 */
74
	protected function getHttpClient()
75
	{
76
		return $this->httpClient;
77
	}
78
79
	protected function getBasePath($action)
80
	{
81
		return sprintf(
82
			'project/%s/%s?key=%s',
83
			$this->getProjectId(),
84
			$action,
85
			$this->getApiKey()
86
		);
87
88
	}
89
}
90