summaryrefslogtreecommitdiff
path: root/scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidMethod.php
blob: a52988aa6dd34e7e51ae16e77134b4b56fa4f942 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php

/**
 * Check that the method name is valid
 *
 */
class gtIsValidMethod extends gtPreCondition {

 public function check( $clo) {
    if($clo->hasOption('m') ) {
      $className = $clo->getOption('c');
      $class = new ReflectionClass($className);
      $methods = $class->getMethods();
      foreach($methods as $method) {
        if($clo->getOption('m') == $method->getName()) {
          return true;
        }
      }
      return false;
    }
    return true;
  }

  public function getMessage() {
    return gtText::get('unknownMethod');
  }
}
?>