| 1 |
<?php |
| 2 |
/** |
| 3 |
* class-groups-cache-object.php |
| 4 |
* |
| 5 |
* Copyright (c) "kento" Karim Rahimpur www.itthinx.com |
| 6 |
* |
| 7 |
* This code is released under the GNU General Public License. |
| 8 |
* See COPYRIGHT.txt and LICENSE.txt. |
| 9 |
* |
| 10 |
* This code is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* This header and all notices must be kept intact. |
| 16 |
* |
| 17 |
* @author Karim Rahimpur |
| 18 |
* @package groups |
| 19 |
* @since groups 1.9.0 |
| 20 |
*/ |
| 21 |
|
| 22 |
if ( !defined( 'ABSPATH' ) ) { |
| 23 |
exit; |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Cache entry encapsulation. |
| 28 |
* |
| 29 |
* @property string $key |
| 30 |
* @property mixed $value |
| 31 |
*/ |
| 32 |
class Groups_Cache_Object { |
| 33 |
|
| 34 |
/** |
| 35 |
* Cache key. |
| 36 |
* @var string |
| 37 |
*/ |
| 38 |
private $key = null; |
| 39 |
|
| 40 |
/** |
| 41 |
* Cached value. |
| 42 |
* @var mixed |
| 43 |
*/ |
| 44 |
private $value = null; |
| 45 |
|
| 46 |
/** |
| 47 |
* Create a cache entry object that holds a value for the given key. |
| 48 |
* |
| 49 |
* @param string $key |
| 50 |
* @param mixed $value |
| 51 |
*/ |
| 52 |
public function __construct( $key, $value ) { |
| 53 |
$this->key = $key; |
| 54 |
$this->value = $value; |
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* Getter implementation for key and value properties. |
| 59 |
* |
| 60 |
* @param string $name |
| 61 |
* @return property value or null |
| 62 |
*/ |
| 63 |
public function __get( $name ) { |
| 64 |
$result = null; |
| 65 |
switch ( $name ) { |
| 66 |
case 'key' : |
| 67 |
case 'value' : |
| 68 |
$result = $this->$name; |
| 69 |
break; |
| 70 |
} |
| 71 |
return $result; |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* Setter for key and value properties. |
| 76 |
* |
| 77 |
* @param string $name |
| 78 |
* @param mixed $value |
| 79 |
*/ |
| 80 |
public function __set( $name, $value ) { |
| 81 |
switch( $name ) { |
| 82 |
case 'key' : |
| 83 |
case 'value' : |
| 84 |
$this->$name = $value; |
| 85 |
break; |
| 86 |
} |
| 87 |
} |
| 88 |
} |
| 89 |
|