Languagefile   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 111
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
c 1
b 0
f 0
lcom 3
cbo 0
dl 0
loc 111
ccs 20
cts 20
cp 1
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
A getCrowdinPath() 0 4 1
A setExportPattern() 0 6 1
A setTitle() 0 6 1
A getLocalPath() 0 4 2
A getExportPattern() 0 4 2
A getTitle() 0 4 2
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
/**
12
 * Language file class.
13
 *
14
 * @since  1.0.1
15
 */
16
class Languagefile
17
{
18
	/**
19
	 * The path on the local file system.
20
	 * @var string
21
	 */
22
	protected $localPath;
23
24
	/**
25
	 * The path at crowdin.
26
	 * @var string
27
	 */
28
	protected $crowdinPath;
29
30
	/**
31
	 * The language file title.
32
	 * @var string
33
	 */
34
	protected $title;
35
36
	/**
37
	 * The export pattern.
38
	 * @var string
39
	 */
40
	protected $exportPattern;
41
42
	/**
43
	 * Constructor.
44
	 *
45
	 * @param   string  $localPath    The path on the local file system.
46
	 * @param   string  $crowdinPath  The path on Crowdin.
47
	 */
48 1
	public function __construct(string $localPath, string $crowdinPath)
49
	{
50 1
		if (!file_exists($localPath))
51
		{
52 1
			throw new \InvalidArgumentException(sprintf('File %s does not exist', $localPath));
53
		}
54
55 1
		$this->localPath = $localPath;
56 1
		$this->crowdinPath = $crowdinPath;
57 1
	}
58
59
	/**
60
	 * Get the local path.
61
	 *
62
	 * @return string
63
	 */
64 1
	public function getLocalPath() : string
65
	{
66 1
		return $this->localPath ?: '';
67
	}
68
69
	/**
70
	 * Get the Crowdin path.
71
	 *
72
	 * @return string
73
	 */
74 1
	public function getCrowdinPath() : string
75
	{
76 1
		return $this->crowdinPath;
77
	}
78
79
	/**
80
	 * Set the export pattern.
81
	 *
82
	 * @param   string  $exportPattern  The export pattern.
83
	 *
84
	 * @return $this
85
	 */
86 1
	public function setExportPattern(string $exportPattern)
87
	{
88 1
		$this->exportPattern = $exportPattern;
89
90 1
		return $this;
91
	}
92
93
	/**
94
	 * Get the export pattern.
95
	 *
96
	 * @return string
97
	 */
98 1
	public function getExportPattern() : string
99
	{
100 1
		return $this->exportPattern ?: '';
101
	}
102
103
	/**
104
	 * Set the title.
105
	 *
106
	 * @param   string  $title  The title.
107
	 *
108
	 * @return $this
109
	 */
110 1
	public function setTitle(string $title)
111
	{
112 1
		$this->title = $title;
113
114 1
		return $this;
115
	}
116
117
	/**
118
	 * Get the title.
119
	 *
120
	 * @return string
121
	 */
122 1
	public function getTitle() : string
123
	{
124 1
		return $this->title ?: '';
125
	}
126
}
127