<?php
/*******************************************************************
 * BasicService.php
 * Copyright (C) 2006 Midnight Coders, LLC
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * The software is licensed under the GNU General Public License (GPL)
 * For details, see http://www.gnu.org/licenses/gpl.txt.
 ********************************************************************/
class BasicService
{
    var $ADD = 1;
    var $SUBTRACT = 2;
    var $MULTIPLY = 3;
    var $DIVIDE = 4;

    // Flex client invokes the Calculate method to demonstrate
    // the use of RemoteObject to connect with PHP.
    // Notice the data type Flex passes into the remote invocation
    // is string, but the arguments in the Calculate method are
    // integers. WebORB performs the conversion from String to int
    // before it dispatches the invocation
    public function Calculate($arg1, $op, $arg2 )
    {
        switch( $op )
        {
            case $this->ADD:
                return $arg1 + $arg2;

            case $this->SUBTRACT:
                return $arg1 - $arg2;

            case $this->MULTIPLY:
                return $arg1 * $arg2;

            case $this->DIVIDE:
                return $arg1 / $arg2;

            default:
                throw new Exception( "unknown operation" );
        }
    }
}
?>