1 | <?php |
||
11 | class Spreadsheet |
||
12 | { |
||
13 | /** @var string */ |
||
14 | protected $id; |
||
15 | |||
16 | /** @var array */ |
||
17 | protected $locales; |
||
18 | |||
19 | /** @var array */ |
||
20 | protected $translations; |
||
21 | |||
22 | /** @var Api */ |
||
23 | protected $api; |
||
24 | |||
25 | 18 | public function __construct($id, $locales, $api = null) |
|
26 | { |
||
27 | 18 | $this->id = $id; |
|
28 | 18 | $this->locales = $locales; |
|
29 | 18 | $this->api = $api ?: app(Api::class); |
|
30 | 18 | } |
|
31 | |||
32 | 3 | public function setLocales($locales) |
|
33 | { |
||
34 | 3 | $this->locales = $locales; |
|
35 | |||
36 | 3 | return $this; |
|
37 | } |
||
38 | |||
39 | 17 | public function setTranslations($translations) |
|
40 | { |
||
41 | 17 | $this->translations = $translations; |
|
42 | |||
43 | 17 | return $this; |
|
44 | } |
||
45 | |||
46 | 1 | public function getTranslations() |
|
47 | { |
||
48 | 1 | return $this->translations; |
|
49 | } |
||
50 | |||
51 | 3 | public function getTranslationsCount() |
|
52 | { |
||
53 | 3 | return count($this->translations); |
|
54 | } |
||
55 | |||
56 | 3 | public function getId() |
|
57 | { |
||
58 | 3 | return $this->id; |
|
59 | } |
||
60 | |||
61 | 1 | public function getUrl() |
|
62 | { |
||
63 | 1 | return 'https://docs.google.com/spreadsheets/d/'.$this->id; |
|
64 | } |
||
65 | |||
66 | 10 | public function getLocales() |
|
67 | { |
||
68 | 10 | return $this->locales; |
|
69 | } |
||
70 | |||
71 | 4 | public function getLocalesCount() |
|
72 | { |
||
73 | 4 | return count($this->locales); |
|
74 | } |
||
75 | |||
76 | 7 | public function getHeader() |
|
77 | { |
||
78 | 7 | return array_merge( |
|
79 | 7 | array_merge(['Full key'], $this->getLocales()), |
|
80 | 7 | ['Namespace', 'Group', 'Key', 'Source file'] |
|
81 | 7 | ); |
|
82 | } |
||
83 | |||
84 | public function getCamelizedHeader() |
||
94 | |||
95 | 4 | public function getHeaderColumnsCount() |
|
96 | { |
||
97 | 4 | $header = $this->getHeader(); |
|
98 | |||
99 | 4 | return count($header); |
|
100 | } |
||
101 | |||
102 | 3 | public function getHeaderRowsCount() |
|
103 | { |
||
104 | 3 | return 1; |
|
106 | |||
107 | /** |
||
108 | * @param $sheetId |
||
109 | * @param $sheetTitle |
||
110 | * |
||
111 | * @return TranslationsSheetCoordinates |
||
112 | */ |
||
113 | 1 | public function translationsEmptySheetCoordinates($sheetId, $sheetTitle) |
|
121 | |||
122 | /** |
||
123 | * @param $sheetId |
||
124 | * @param $sheetTitle |
||
125 | * @return TranslationsSheetCoordinates |
||
126 | */ |
||
127 | 2 | public function translationsSheetCoordinates($sheetId, $sheetTitle) |
|
136 | |||
137 | 1 | public function sheetStyles() |
|
141 | |||
142 | /** |
||
143 | * Return api instance initialized with the spreadsheet ID. |
||
144 | * |
||
145 | * @return Api |
||
146 | */ |
||
147 | 1 | public function api() |
|
151 | } |
||
152 |