1<?php 2/** 3 * Tivoka - JSON-RPC done right! 4 * Copyright (c) 2011-2012 by Marcel Klehr <mklehr@gmx.net> 5 * 6 * MIT LICENSE 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining a copy 9 * of this software and associated documentation files (the "Software"), to deal 10 * in the Software without restriction, including without limitation the rights 11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 * copies of the Software, and to permit persons to whom the Software is 13 * furnished to do so, subject to the following conditions: 14 * 15 * The above copyright notice and this permission notice shall be included in 16 * all copies or substantial portions of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 * THE SOFTWARE. 25 * 26 * @package Tivoka 27 * @author Marcel Klehr <mklehr@gmx.net> 28 * @copyright (c) 2011-2012, Marcel Klehr 29 */ 30 31namespace Tivoka; 32 33/** 34 * The public interface to all tivoka functions 35 * @package Tivoka 36 */ 37abstract class Tivoka 38{ 39 const SPEC_1_0 = 8; // 000 001 000 40 const SPEC_2_0 = 16; // 000 010 000 41 42 /** 43 * Evaluates and returns the passed JSON-RPC spec version 44 * @private 45 * 46 * @param string $version spec version as a string (using semver notation) 47 * 48 * @return int 49 * @throws Exception\SpecException 50 */ 51 public static function validateSpecVersion($version) 52 { 53 switch($version) { 54 case '1.0': 55 return Tivoka::SPEC_1_0; 56 break; 57 case '2.0': 58 return Tivoka::SPEC_2_0; 59 default: 60 throw new Exception\SpecException('Unsupported spec version: '+$version); 61 } 62 } 63} 64?> 65