These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\TranslatorBundle\Model\Export; |
||
4 | |||
5 | use Doctrine\Common\Collections\ArrayCollection; |
||
6 | use Kunstmaan\TranslatorBundle\Entity\Translation; |
||
7 | |||
8 | /** |
||
9 | * A representation of a translation export into a file |
||
10 | */ |
||
11 | class ExportFile |
||
12 | { |
||
13 | private $extension; |
||
14 | |||
15 | private $domain; |
||
16 | |||
17 | private $locale; |
||
18 | |||
19 | /** |
||
20 | * ArrayCollection with keyword as key, text as value |
||
21 | * |
||
22 | * @var ArrayCollection |
||
23 | */ |
||
24 | private $translations; |
||
25 | |||
26 | /** |
||
27 | * Translations converted into an array |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | private $array = []; |
||
32 | |||
33 | private $content = ''; |
||
34 | |||
35 | 1 | public function __construct() |
|
36 | { |
||
37 | 1 | $this->translations = new ArrayCollection(); |
|
38 | 1 | } |
|
39 | |||
40 | public function fillArray() |
||
41 | { |
||
42 | foreach ($this->translations as $keyword => $text) { |
||
43 | $this->assignArrayByPath($array, $keyword, $text); |
||
44 | $this->array = array_merge_recursive($array, $this->array); |
||
45 | } |
||
46 | } |
||
47 | |||
48 | public function assignArrayByPath(&$arr, $path, $value) |
||
49 | { |
||
50 | $keys = explode('.', $path); |
||
51 | |||
52 | while ($key = array_shift($keys)) { |
||
53 | $arr = &$arr[$key]; |
||
54 | } |
||
55 | |||
56 | $arr = $value; |
||
57 | } |
||
58 | |||
59 | public function getExtension() |
||
0 ignored issues
–
show
|
|||
60 | { |
||
61 | return $this->extension; |
||
62 | } |
||
63 | |||
64 | 1 | public function setExtension($extension) |
|
65 | { |
||
66 | 1 | $this->extension = $extension; |
|
67 | 1 | } |
|
68 | |||
69 | public function getDomain() |
||
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a
Loading history...
|
|||
70 | { |
||
71 | return $this->domain; |
||
72 | } |
||
73 | |||
74 | 1 | public function setDomain($domain) |
|
75 | { |
||
76 | 1 | $this->domain = $domain; |
|
77 | 1 | } |
|
78 | |||
79 | public function getLocale() |
||
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a
Loading history...
|
|||
80 | { |
||
81 | return $this->locale; |
||
82 | } |
||
83 | |||
84 | 1 | public function setLocale($locale) |
|
85 | { |
||
86 | 1 | $this->locale = $locale; |
|
87 | 1 | } |
|
88 | |||
89 | public function getTranslations() |
||
90 | { |
||
91 | return $this->translations; |
||
92 | } |
||
93 | |||
94 | public function setTranslations($translations) |
||
95 | { |
||
96 | $this->translations = $translations; |
||
97 | } |
||
98 | |||
99 | public function getContent() |
||
100 | { |
||
101 | return $this->content; |
||
102 | } |
||
103 | |||
104 | public function setContent($content) |
||
105 | { |
||
106 | $this->content = $content; |
||
107 | } |
||
108 | |||
109 | 1 | public function addTranslation(Translation $translation) |
|
110 | { |
||
111 | 1 | $this->translations->set($translation->getKeyword(), $translation->getText()); |
|
112 | 1 | } |
|
113 | |||
114 | public function getArray() |
||
115 | { |
||
116 | return $this->array; |
||
117 | } |
||
118 | |||
119 | public function setArray($array) |
||
120 | { |
||
121 | $this->array = $array; |
||
122 | } |
||
123 | } |
||
124 |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@return
annotation as described here.