Mercurial > hg > cmmr2012-drupal-site
comparison vendor/chi-teck/drupal-code-generator/src/Box/PhpCompactor.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
1 <?php | |
2 | |
3 namespace DrupalCodeGenerator\Box; | |
4 | |
5 use Herrera\Box\Compactor\Compactor; | |
6 | |
7 /** | |
8 * A PHP source code compactor. | |
9 */ | |
10 class PhpCompactor extends Compactor { | |
11 | |
12 /** | |
13 * {@inheritdoc} | |
14 */ | |
15 protected $extensions = ['php']; | |
16 | |
17 /** | |
18 * {@inheritdoc} | |
19 */ | |
20 public function compact($contents) { | |
21 // php_strip_whitespace() takes file name as argument so we have to save the | |
22 // contents to a temporary file. | |
23 $temp_file = tempnam(sys_get_temp_dir(), 'dcg-'); | |
24 file_put_contents($temp_file, $contents); | |
25 $contents = php_strip_whitespace($temp_file); | |
26 unlink($temp_file); | |
27 return $contents; | |
28 } | |
29 | |
30 } |