1<?php 2/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 3 4/** 5 * Service object 6 * 7 * PHP version 5 8 * 9 * This library is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU Lesser General Public 11 * License as published by the Free Software Foundation; either 12 * version 2.1 of the License. 13 * 14 * This library is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public 20 * License along with this library; if not, write to the Free Software 21 * Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA 22 * 23 * @category Net 24 * @package Net_Nmap 25 * @author Luca Corbo <lucor@ortro.net> 26 * @copyright 2008 Luca Corbo 27 * @license GNU/LGPL v2.1 28 * @link http://pear.php.net/packages/Net_Nmap 29 */ 30 31require_once 'Net/Nmap/Exception.php'; 32 33/** 34 * Service object 35 * 36 * @property string $protocol The protocol type of the service. 37 * @property int $port The port number where the service is running on. 38 * @property string $name The name of the service. 39 * @property string $product The product information of the service. 40 * @property string $version The version of the product running as service. 41 * @property string $extrainfo The additional information about the product 42 * running as service. 43 * 44 * @category Net 45 * @package Net_Nmap 46 * @author Luca Corbo <lucor@ortro.net> 47 * @copyright 2008 Luca Corbo 48 * @license GNU/LGPL v2.1 49 * @link http://www.ortro.net 50 */ 51class Net_Nmap_Service 52{ 53 /** 54 * The list of properties managed by __set and __get methods 55 * 56 * @var array $_properties 57 */ 58 private $_properties = array('product' => null, 59 'protocol' => null, 60 'port' => null, 61 'name' => null, 62 'version' => null, 63 'extrainfo' => null); 64 65 /** 66 * Overloading of the __get method 67 * 68 * @param string $key The name of the variable that should be retrieved 69 * 70 * @throws Net_Nmap_Exception If trying to get an undefined properties. 71 * @return mixed The value of the object on success 72 */ 73 public function __get($key) 74 { 75 if (array_key_exists($key, $this->_properties)) { 76 return $this->_properties[$key]; 77 } 78 79 throw new Net_Nmap_Exception( 80 'Trying to get an undefined properties "' . 81 $key . '" for the object ' . __CLASS__ 82 ); 83 } 84 85 /** 86 * Overloading of the __set method 87 * 88 * @param string $key The name of the properties that should be set 89 * @param mixed $value parameter specifies the value that the object 90 * should set the $key 91 * 92 * @throws Net_Nmap_Exception If trying to set an undefined properties. 93 * @return mixed True on success 94 */ 95 public function __set($key, $value) 96 { 97 if (array_key_exists($key, $this->_properties)) { 98 $this->_properties[$key] = $value; 99 return true; 100 } 101 102 throw new Net_Nmap_Exception( 103 'Trying to set an undefined properties "' . 104 $key . '" for the object ' . __CLASS__ 105 ); 106 } 107} 108