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