1 | <?php |
||
9 | class Composer extends AbstractFile |
||
10 | { |
||
11 | const JSON_FILE_EXTENSION = 'json'; |
||
12 | /** |
||
13 | * Tests purpose: do not run composer update command |
||
14 | * @var bool |
||
15 | */ |
||
16 | protected $runComposerUpdate = true; |
||
17 | /** |
||
18 | * @see \WsdlToPhp\PackageGenerator\File\AbstractFile::writeFile() |
||
19 | * @return int|bool |
||
20 | */ |
||
21 | 24 | protected function writeFile() |
|
53 | /** |
||
54 | * @return Composer |
||
55 | */ |
||
56 | 24 | protected function addAutoloadToComposerJson() |
|
66 | /** |
||
67 | * @return array |
||
68 | */ |
||
69 | 24 | protected function getPsr4Autoload() |
|
81 | /** |
||
82 | * @return array |
||
83 | */ |
||
84 | 24 | protected function getComposerFileContent() |
|
85 | 3 | { |
|
86 | 24 | $content = array(); |
|
87 | 24 | $composerFilePath = $this->getComposerFilePath(); |
|
88 | 24 | if (!empty($composerFilePath)) { |
|
89 | 24 | $content = json_decode(file_get_contents($composerFilePath), true); |
|
90 | 18 | } |
|
91 | 24 | return $content; |
|
92 | } |
||
93 | /** |
||
94 | * @param array $content |
||
95 | * @return Composer |
||
96 | */ |
||
97 | 24 | protected function setComposerFileContent(array $content) |
|
105 | /** |
||
106 | * @param array $content |
||
107 | * @return string |
||
108 | */ |
||
109 | 24 | protected static function encodeToJson($content) |
|
110 | { |
||
111 | 24 | if (version_compare(PHP_VERSION, '5.4.0') === -1) { |
|
112 | $json = str_replace('\/', '/', json_encode($content)); |
||
113 | } else { |
||
114 | 24 | $json = json_encode($content, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
|
115 | } |
||
116 | 24 | return $json; |
|
117 | } |
||
118 | /** |
||
119 | * @return string |
||
120 | */ |
||
121 | 24 | protected function getComposerFilePath() |
|
125 | /** |
||
126 | * @param bool $runComposerUpdate |
||
127 | * @return Composer |
||
128 | */ |
||
129 | 8 | public function setRunComposerUpdate($runComposerUpdate) |
|
134 | /** |
||
135 | * @return bool |
||
136 | */ |
||
137 | 28 | public function getRunComposerUpdate() |
|
141 | /** |
||
142 | * @return string |
||
143 | */ |
||
144 | 8 | public function getFileExtension() |
|
148 | } |
||
149 |