| 1 | <?php |
||
| 13 | * @package Msls |
||
| 14 | */ |
||
| 15 | class MslsJson { |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Container |
||
| 19 | * @var array |
||
| 20 | */ |
||
| 21 | protected $arr = array(); |
||
| 22 | |||
| 23 | /** |
||
| 24 | * add |
||
| 25 | * @param int $value |
||
| 26 | * @param string $label |
||
| 27 | * @return MslsJson |
||
| 28 | */ |
||
| 29 | public function add( $value, $label ) { |
||
| 36 | |||
| 37 | /** |
||
| 38 | * compare |
||
| 39 | * |
||
| 40 | * Compare the item with the key "label" of the array $a and the |
||
| 41 | * array $b |
||
| 42 | * @param array $a |
||
| 43 | * @param array $b |
||
| 44 | * @return int |
||
| 45 | */ |
||
| 46 | public static function compare( array $a, array $b ) { |
||
| 49 | |||
| 50 | /** |
||
| 51 | * get |
||
| 52 | * |
||
| 53 | * Get the array container sorted by label |
||
| 54 | * @return array |
||
| 55 | */ |
||
| 56 | public function get() { |
||
| 63 | |||
| 64 | /** |
||
| 65 | * encode |
||
| 66 | * |
||
| 67 | * Encodes object and returns it as a json-string |
||
| 68 | * @return string |
||
| 69 | */ |
||
| 70 | public function encode() { |
||
| 73 | |||
| 74 | /** |
||
| 75 | * __toString |
||
| 76 | * |
||
| 77 | * Return the encoded object as a string using the encode-method |
||
| 78 | * @uses encode |
||
| 79 | * @return string |
||
| 80 | */ |
||
| 81 | public function __toString() { |
||
| 82 | return $this->encode(); |
||
| 86 |