original_string: public function cacheFun($function) {
          if ($this->getConfig('debug') && !is_callable($function))
              echo "no valid function";
  
          $r = new ReflectionFunction($function);
          $id = null;
  
          foreach ($r->getStaticVariables() as $key => $var) {
              if ($key == 'key')
                  $id = $var;
          }
  
          if (is_object($id))
              $id = $this->getIDfromOjb($id);
  
          if ($id == null && $this->getConfig('debug')) {
              echo "no caching key";
              return $function();
          }
  
          $cachefile = $this->getConfig('cacheDir') . '/' . utf8_decode($id);
          $cachetime = $this->getConfig('cacheTime');
  
          if (file_exists($cachefile) && time() - $cachetime < fileatime($cachefile)) {
              $ser = file_get_contents($cachefile);
              $val = bzdecompress(unserialize($ser));
              return $val;
          } else {
              $value = $function();
              $ser = serialize(bzcompress($value));
              file_put_contents($cachefile, $ser);
              return $value;
          }
  
          if ($this->getConfig('debug'))
              echo "no caching";
      }
code: public function cacheFun($function) {
          if ($this->getConfig('debug') && !is_callable($function))
              echo "no valid function";
  
          $r = new ReflectionFunction($function);
          $id = null;
  
          foreach ($r->getStaticVariables() as $key => $var) {
              if ($key == 'key')
                  $id = $var;
          }
  
          if (is_object($id))
              $id = $this->getIDfromOjb($id);
  
          if ($id == null && $this->getConfig('debug')) {
              echo "no caching key";
              return $function();
          }
  
          $cachefile = $this->getConfig('cacheDir') . '/' . utf8_decode($id);
          $cachetime = $this->getConfig('cacheTime');
  
          if (file_exists($cachefile) && time() - $cachetime < fileatime($cachefile)) {
              $ser = file_get_contents($cachefile);
              $val = bzdecompress(unserialize($ser));
              return $val;
          } else {
              $value = $function();
              $ser = serialize(bzcompress($value));
              file_put_contents($cachefile, $ser);
              return $value;
          }
  
          if ($this->getConfig('debug'))
              echo "no caching";
      }
code_tokens: public function cacheFun ( $ function ) { if ( $ this -> getConfig ( 'debug' ) && ! is_callable ( $ function ) ) echo "no valid function" ; $ r = new ReflectionFunction ( $ function ) ; $ id = null ; foreach ( $ r -> getStaticVariables ( ) as $ key => $ var ) { if ( $ key == 'key' ) $ id = $ var ; } if ( is_object ( $ id ) ) $ id = $ this -> getIDfromOjb ( $ id ) ; if ( $ id == null && $ this -> getConfig ( 'debug' ) ) { echo "no caching key" ; return $ function ( ) ; } $ cachefile = $ this -> getConfig ( 'cacheDir' ) . '/' . utf8_decode ( $ id ) ; $ cachetime = $ this -> getConfig ( 'cacheTime' ) ; if ( file_exists ( $ cachefile ) && time ( ) - $ cachetime < fileatime ( $ cachefile ) ) { $ ser = file_get_contents ( $ cachefile ) ; $ val = bzdecompress ( unserialize ( $ ser ) ) ; return $ val ; } else { $ value = $ function ( ) ; $ ser = serialize ( bzcompress ( $ value ) ) ; file_put_contents ( $ cachefile , $ ser ) ; return $ value ; } if ( $ this -> getConfig ( 'debug' ) ) echo "no caching" ; }
docstring: cache function result and return it
  @param $function closure to cache
  @return object
docstring_tokens: cache function result and return it