| Conditions | 5 | 
| Paths | 5 | 
| Total Lines | 25 | 
| Code Lines | 14 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 3 | ||
| Bugs | 0 | Features | 1 | 
| 1 | <?php | ||
| 19 | public static function create($file, $classname) | ||
| 20 |     { | ||
| 21 |         if (is_object($classname)) { | ||
| 22 | return $classname; | ||
| 23 | } | ||
| 24 | |||
| 25 |         if (empty($classname)) { | ||
| 26 |             throw new \InvalidArgumentException("empty class name"); | ||
| 27 | } | ||
| 28 | |||
| 29 |         if (!class_exists($classname)) { | ||
| 30 | throw new \RuntimeException($classname . ' class is not exists'); | ||
| 31 | } | ||
| 32 | |||
| 33 | $reflect = new \ReflectionClass($classname); | ||
| 34 | $parent_class = "\\AdTeam\\LogMonitor\\Reader\\ReaderInterface"; | ||
| 35 |         if (!$reflect->isSubclassOf($parent_class)) { | ||
| 36 | throw new \RuntimeException($classname . ' must be a sub class of ' . $parent_class); | ||
| 37 | } | ||
| 38 | |||
| 39 | $obj = new $classname(); | ||
| 40 | $obj->configure($file); | ||
| 41 | |||
| 42 | return $obj; | ||
| 43 | } | ||
| 44 | } |