Rev 45 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 45 | Rev 51 | ||
---|---|---|---|
1 | <?php
|
1 | <?php
|
2 | 2 | ||
- | 3 | namespace PointedEars\PHPX; |
|
- | 4 | ||
3 | /**
|
5 | /**
|
4 | * Basic registry class
|
6 | * Basic registry class
|
5 | *
|
7 | *
|
6 | * @author Thomas Lahn
|
8 | * @author Thomas Lahn
|
7 | */
|
9 | */
|
8 | abstract class Registry |
10 | abstract class Registry |
9 | {
|
11 | {
|
10 | /**
|
12 | /**
|
11 | * Data storage
|
13 | * Data storage
|
12 | * @var array
|
14 | * @var array
|
13 | */
|
15 | */
|
14 | protected static $_data = array(); |
16 | protected static $_data = array(); |
15 | 17 | ||
16 | /**
|
18 | /**
|
17 | * Puts data in storage
|
19 | * Puts data in storage
|
18 | *
|
20 | *
|
19 | * @param string $key
|
21 | * @param string $key
|
20 | * @param mixed $value
|
22 | * @param mixed $value
|
21 | * @return mixed The stored value
|
23 | * @return mixed The stored value
|
22 | */
|
24 | */
|
23 | public static function set($key, $value) |
25 | public static function set($key, $value) |
24 | {
|
26 | {
|
25 | self::$_data[$key] = $value; |
27 | self::$_data[$key] = $value; |
26 | return self::get($key); |
28 | return self::get($key); |
27 | }
|
29 | }
|
28 | 30 | ||
29 | /**
|
31 | /**
|
30 | * Gets data from storage
|
32 | * Gets data from storage
|
31 | *
|
33 | *
|
32 | * @param string $key
|
34 | * @param string $key
|
33 | * @return mixed
|
35 | * @return mixed
|
34 | */
|
36 | */
|
35 | public static function get($key) |
37 | public static function get($key) |
36 | {
|
38 | {
|
37 | return self::$_data[$key]; |
39 | return self::$_data[$key]; |
38 | }
|
40 | }
|
39 | }
|
41 | }
|