These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /*************************************************************************** |
||
3 | * @title PH7 Template Engine |
||
4 | * @desc Main Predefined Abstract Class |
||
5 | * |
||
6 | * @updated Last Update 09/14/13 23:22 |
||
7 | * @author Pierre-Henry Soria <[email protected]> |
||
8 | * @category PH7 Template Engine |
||
9 | * @package PH7 / Framework / Layout / Tpl / Engine / PH7Tpl |
||
10 | * @copyright (c) 2012-2017, Pierre-Henry Soria. All Rights Reserved. |
||
11 | * @version 1.0.1 |
||
12 | * @license CC-BY License - http://creativecommons.org/licenses/by/3.0/ |
||
13 | * |
||
14 | ***************************************************************************/ |
||
15 | |||
16 | namespace PH7\Framework\Layout\Tpl\Engine\PH7Tpl\Predefined; |
||
17 | defined('PH7') or exit('Restricted access'); |
||
18 | |||
19 | abstract class Predefined |
||
20 | { |
||
21 | |||
22 | const PHP_OPEN = '<?php ', PHP_CLOSE = '?>', WRITE = 'echo '; |
||
23 | |||
24 | protected $sCode, $sLeftDelim = '{', $sRightDelim = '}'; |
||
0 ignored issues
–
show
|
|||
25 | |||
26 | /** |
||
27 | * @param string $sCode |
||
28 | * @return void |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Adding a
@return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.
Adding a Please refer to the PHP core documentation on constructors.
Loading history...
|
|||
29 | */ |
||
30 | public function __construct($sCode) |
||
31 | { |
||
32 | $this->sCode = $sCode; |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Adding Variable. |
||
37 | * |
||
38 | * @access protected |
||
39 | * @param string $sKey |
||
40 | * @param string $sValue |
||
41 | * @param boolean Print the variable. Default TRUE |
||
42 | * @return void |
||
43 | */ |
||
44 | protected function addVar($sKey, $sValue, $bPrint = true) |
||
45 | { |
||
46 | $this->sCode = str_replace('$' . $sKey, $sValue, $this->sCode); |
||
47 | $this->sCode = str_replace($this->sLeftDelim . $sKey . $this->sRightDelim, static::PHP_OPEN . ($bPrint ? static::WRITE : '') . $sValue . static::PHP_CLOSE, $this->sCode); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Adding Function. |
||
52 | * |
||
53 | * @access protected |
||
54 | * @param string $sKey |
||
55 | * @param string $sValue |
||
56 | * @return void |
||
57 | */ |
||
58 | protected function addFunc($sKey, $sValue) |
||
59 | { |
||
60 | $this->sCode = preg_replace('#' . $sKey . '#', static::PHP_OPEN . static::WRITE . $sValue . static::PHP_CLOSE, $this->sCode); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * Gets the parsed variables. |
||
65 | * |
||
66 | * @return string |
||
67 | */ |
||
68 | public function get() |
||
69 | { |
||
70 | return $this->sCode; |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * @return object this |
||
75 | */ |
||
76 | abstract public function assign(); |
||
77 | |||
78 | } |
||
79 |
Only declaring a single property per statement allows you to later on add doc comments more easily.
It is also recommended by PSR2, so it is a common style that many people expect.