Test Failed
Branch master (8beb08)
by Federico
09:24 queued 04:24
created

block.php ➔ jBlockParsing()   B

Complexity

Conditions 7
Paths 7

Size

Total Lines 21
Code Lines 19

Duplication

Lines 21
Ratio 100 %

Importance

Changes 0
Metric Value
cc 7
eloc 19
nc 7
nop 3
dl 21
loc 21
rs 7.551
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A block.php ➔ minifyOutput() 0 7 3
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 4 and the first side effect is on line 2.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
  jRequire("../modules/Parser/Parser.php");
3
  jRequire("../modules/JException/JException.php");
4
  function jBlock() {
5
    return ob_start();
6
  }
7
8
  function jBlockClose( $_type = "html", $_parameters = [] ) {
9
    return jBlockEnd($_type, $_parameters);
10
  }
11
12
  function jBlockFile( $_path, $_parameters = [] ) {
13
    try {
14
      $temp = Parser::parseFile($_path, $_parameters);
15
    } catch (Exception $e) {
16
      throw new JException($e->getMessage());
17
    }
18
    return $temp;
19
  }
20
21
  function jBlockFileMan( $_path, $_type, $_parameters = [] ) {
22
    try {
23
      $temp = Parser::parseFileMan($_path, $_parameters, $_type);
24
    } catch (Exception $e) {
25
      throw new JException($e->getMessage());
26
    }
27
    return $temp;
28
  }
29
30
  function jBlockEnd( $_type = "html", $_parameters = [] ) {
31
    $text = ob_get_clean();
32
    try {
33
      $temp = Parser::parseText($text, $_parameters, $_type);
34
    } catch (Exception $e) {
35
      throw new JException($e->getMessage());
36
    }
37
    return $temp;
38
  }
39
40
  function minifyOutput($_buffer) {
41
    $search = array ( '/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s' );
42
    $replace = array ( '>', '<', '\\1' );
43
    if (preg_match("/\<html/i",$_buffer) == 1 && preg_match("/\<\/html\>/i",$_buffer) == 1)
44
      $_buffer = preg_replace($search, $replace, utf8_decode($_buffer));
45
    return utf8_encode($_buffer);
46
  }
47
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
48