PHP Classes

File: public/Classes/Operationen/Sinus.php

Recommend this page to a friend!
  Classes of stefan   PHP Calculator   public/Classes/Operationen/Sinus.php   Download  
File: public/Classes/Operationen/Sinus.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PHP Calculator
Calculate the result of multiple math operations
Author: By
Last change: resolve error ( and sin( in same term
Date: 2 years ago
Size: 872 bytes
 

Contents

Class file image Download
<?php

namespace Taschenrechner\Classes\Operationen;
class
Sinus extends Operation {
    public function
getSign() {
        return
"sin(";
    }

    public function
calculate($a, $b=NULL) {
        return
sin(deg2rad($a));
    }

    public function
findAndCalculateTerm($term, $operations) {
           
//arbeitet intern mit dem Array
           
$array = preg_split('/(?<!^)(?!$)/u', $term );
              
           
$array = $this->concatinator->concatinateArray($array, $operations);
           
            for(
$i = 0; $i < sizeof($array); $i++) {
                if(
$array[$i]===$this->getSign()) {
                   
$array[$i] = $this->calculate($array[$i+1]);
                    unset(
$array[$i+1]);
                    unset(
$array[$i+2]);
                   
$array = array_values($array);
                }
            }
            return
implode("", $array);
    }
}