PluginProbe
LWS Optimize – All-in-One Speed Booster & Cache Tools / 1.8
LWS Optimize – All-in-One Speed Booster & Cache Tools v1.8
4.1.4 4.1.3 4.1.2 4.1.1 4.1 4.0 3.4.1 3.4 3.3.21 trunk 1.0 1.1 1.2 1.5 1.6 1.6.5 1.7 1.8 1.8.5 1.8.6 1.9 1.9.1 2.0 2.1 2.1.1 All 97 releases
lws-optimize / classes / CssCombiner.php

CssCombiner.php in LWS Optimize – All-in-One Speed Booster & Cache Tools 1.8, at classes/CssCombiner.php

56 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * By Hackinet
5 */
6 class CssCombiner{
7
8 private $fileNames = [];
9
10 function __construct($fileNames){
11 $this->fileNames = $fileNames;
12 }
13
14 private function fileValidator($fileName){
15
16 $fileParts = explode('.',$fileName);
17 $fileExtension = end($fileParts);
18
19 if(strtolower($fileExtension) !== "css"){
20 throw new Exception("Invalid file type. The extension for the file $fileName is $fileExtension.");
21 }
22
23 if(!file_exists($fileName)){
24 throw new Exception("The given file $fileName does not exists.");
25 }
26
27 }
28
29 private function setHeaders(){
30 header('Content-Type: text/css');
31 }
32
33 public function combine(){
34
35 //$this->setHeaders();
36
37 $css = "";
38 $fileNames = $this->fileNames;
39
40 foreach ($fileNames as $fileName){
41 try{
42 $this->fileValidator($fileName);
43 $fileContent = file_get_contents($fileName);
44 $css .= $fileContent;
45 } catch(\Exception $e) {
46 echo 'Message: ' .$e->getMessage();
47 return false;
48 }
49 }
50
51 return $css;
52
53 }
54
55
56 }