public function grade(CodingExecutionResult $result)
 {
     $phpGrader = new PhpGradingTool($result);
     $phpGrader->assertVariableExists('deathStar');
     $deathStar = $result->getDeclaredVariableValue('deathStar');
     if (!$deathStar instanceof \DeathStarII) {
         throw new GradingException('The `$deathStar` variable exists, but is not set to a `DeathStarII` object.');
     }
     if (!$deathStar instanceof \DeathStar) {
         throw new GradingException('The `DeathStarII` class is not extending `DeathStar` one.');
     }
 }
 public function grade(CodingExecutionResult $result)
 {
     $phpGrader = new PhpGradingTool($result);
     $phpGrader->assertVariableExists('original');
     $phpGrader->assertVariableExists('new');
     $original = $result->getDeclaredVariableValue('original');
     $new = $result->getDeclaredVariableValue('new');
     if (!$original instanceof \DeathStar) {
         throw new GradingException('The `$original` variable exists, but is not set to a `DeathStar` object.');
     }
     if (!$new instanceof \DeathStarII) {
         throw new GradingException('The `$new` variable exists, but is not set to a `DeathStarII` object.');
     }
     if (!$new instanceof \DeathStar) {
         throw new GradingException('The `DeathStarII` class is not extending `DeathStar` one.');
     }
     if ('Thermal Exhaust Port' != $original->getWeakness()) {
         throw new GradingException('The return value of `getWeakness()` method in a `DeathStar` class was changed. You should override it.');
     }
     if (null !== $new->getWeakness()) {
         throw new GradingException('The `getWeakness()` method of `DeathStarII` class does not return `null`.');
     }
 }
 public function grade(CodingExecutionResult $result)
 {
     $grader = new GenericGradingTool($result);
     $phpGrader = new PhpGradingTool($result);
     if (!class_exists('\\Cache')) {
         throw new GradingException('Class `Cache` does not exist. Did you create it?');
     }
     $cacheClass = new \ReflectionClass('\\Cache');
     if (!$cacheClass->hasMethod('fetchFromCache')) {
         throw new GradingException('Method `fetchFromCache` does not exist in the `Cache` class.');
     }
     if (!$cacheClass->hasMethod('saveToCache')) {
         throw new GradingException('Method `saveToCache` does not exist in the `Cache` class.');
     }
     $phpGrader->assertVariableExists('transformer', 'I don\'t see the $transformer variable in index.php anymore - did you delete it?');
     $transformer = $result->getDeclaredVariableValue('transformer');
     $transformerClass = new \ReflectionObject($transformer);
     if (!$transformerClass->hasMethod('__construct')) {
         throw new GradingException('Make sure you give the `StringTransformer` class a `__construct()`. It should have one argument: a `Cache` object.');
     }
     $grader->assertInputDoesNotContain('StringTransformer.php', 'file_get_contents', 'I still see `file_get_contents()` inside of `StringTransformer`. Make sure you\'ve moved all of the caching logic into the Cache class');
     // todo - create a mocked Cache, pass it into
     // $transformer and assert that its cache methods are called
 }