-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSection.php
47 lines (39 loc) · 912 Bytes
/
Section.php
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
42
43
44
45
46
47
<?php
namespace Alcatraz\Components\Section;
/**
* Class Section
* @author: Gabriel Malaquias <[email protected]>
* @package Alcatraz\Components
*/
class Section {
/**
* @var array
*/
public static $sections = array();
/**
* @var string
*/
public static $name = null;
/**
* @param $name
* @throws \ErrorException
*/
public static function start($name){
if(static::$name != null)
throw new \ErrorException("Session {$name} not finalized");
static::$name = $name;
ob_start();
}
public static function end(){
static::$sections[static::$name] = ob_get_clean();
static::$name = null;
}
/**
* @param $name
* @return mixed
*/
public static function get($name){
if(isset(static::$sections[$name]))
return static::$sections[$name];
}
}