PHP Classes

File: public/Classes/Operationen/Tan.php

Recommend this page to a friend!
  Classes of stefan  >  PHP Calculator  >  public/Classes/Operationen/Tan.php  >  Download  
File: public/Classes/Operationen/Tan.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: 10 months ago
Size: 929 bytes
 

Contents

Class file image Download
<?php

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

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

    public function
findAndCalculateTerm($term, $operations) {
           
//arbeitet intern mit dem Array
           
$array = preg_split('/(?<!^)(?!$)/u', $term );
              
           
//füge alle darauf folgenden nummerischen werte zusammen
           
$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);
    }
}