forked from ceesvanegmond/minify
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathJavaScript.php
More file actions
38 lines (31 loc) · 841 Bytes
/
JavaScript.php
File metadata and controls
38 lines (31 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
namespace Devfactory\Minify\Providers;
use Devfactory\Minify\Contracts\MinifyInterface;
use JShrink\Minifier;
class JavaScript extends BaseProvider implements MinifyInterface
{
/**
* The extension of the outputted file.
*/
const EXTENSION = '.js';
/**
* @return string
*/
public function minify()
{
$minified = Minifier::minify($this->appended);
return $this->put($minified);
}
/**
* @param $file
* @param array $attributes
* @return string
*/
public function tag($file, array $attributes)
{
// dd($attributes);
// $attributes = array('src' => $file) + $attributes;
$attributes = array_merge(['src' => $file], $attributes);
return "<script {$this->attributes($attributes)}></script>" . PHP_EOL;
}
}