PhpPlaceholder   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 22
c 0
b 0
f 0
rs 10
ccs 8
cts 8
cp 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 12 1
1
<?php
2
3
namespace ArjanSchouten\HtmlMinifier\Placeholders\Php;
4
5
use ArjanSchouten\HtmlMinifier\Placeholders\PlaceholderInterface;
6
7
class PhpPlaceholder implements PlaceholderInterface
8
{
9
    /**
10
     * Replace PHP tags with a temporary placeholder.
11
     *
12
     * @param \ArjanSchouten\HtmlMinifier\MinifyContext $context
13
     *
14
     * @return \ArjanSchouten\HtmlMinifier\MinifyContext
15
     */
16 5
    public function process($context)
17
    {
18 5
        $contents = $context->getContents();
19
        $contents = preg_replace_callback('/<\?=((?!\?>).)*\?>/s', function ($match) use ($context) {
20 1
            return $context->getPlaceholderContainer()->createPlaceholder($match[0]);
21 5
        }, $contents);
22 5
        $contents = preg_replace_callback('/<\?php((?!\?>).)*(\?>)?/s', function ($match) use ($context) {
23 1
            return $context->getPlaceholderContainer()->createPlaceholder($match[0]);
24 5
        }, $contents);
25
26 5
        return $context->setContents($contents);
27
    }
28
}
29