Completed
Push — master ( 149578...a42bb4 )
by Nikolai
02:18
created

Package   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 68.75%

Importance

Changes 4
Bugs 0 Features 3
Metric Value
wmc 5
c 4
b 0
f 3
lcom 1
cbo 0
dl 0
loc 81
ccs 11
cts 16
cp 0.6875
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getProjectId() 0 4 1
A getApiKey() 0 4 1
A getHttpClient() 0 4 1
A __construct() 0 6 1
A getBasePath() 0 9 1
1
<?php
2
/**
3
 * Crowdin API implementation in PHP.
4
 *
5
 * @copyright  Copyright (C) 2016 Nikolai Plath (elkuku)
6
 * @license    WTFPL - See license.txt
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 2
	protected function getProjectId()
58
	{
59 2
		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
	protected function getBasePath($action)
90
	{
91
		return sprintf(
92
			'project/%s/%s?key=%s',
93
			$this->getProjectId(),
94
			$action,
95
			$this->getApiKey()
96
		);
97
	}
98
}
99