-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathConfigurableClosurePlugin.php
More file actions
41 lines (33 loc) · 940 Bytes
/
ConfigurableClosurePlugin.php
File metadata and controls
41 lines (33 loc) · 940 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
39
40
41
<?php
namespace PostCSS\Plugin;
use PostCSS\Processor;
use PostCSS\Result;
use PostCSS\Root;
use PostCSS\Exception\NotConfigurablePlugin;
class ConfigurableClosurePlugin extends ClosurePlugin
{
/**
* @return ClosurePlugin
*/
protected function getClosurePlugin(array $args)
{
$result = call_user_func_array($this->callable, $args);
if (!is_callable($result)) {
throw new NotConfigurablePlugin($this);
}
return new ClosurePlugin($result, $this->name);
}
public function run(Root $root, Result $result)
{
return $this->getClosurePlugin([])->run($root, $result);
}
public function __invoke()
{
return $this->getClosurePlugin(func_get_args());
}
public function process($css, array $options = [])
{
$plugin = $this->getClosurePlugin($options);
return (new Processor([$plugin]))->process($css);
}
}