/**
  * Calculates lcom for file (and not for class)
  *
  * @param string $filename
  * @return Result
  */
 public function calculate($filename)
 {
     $rOOP = $this->classMap->getClassesIn($filename);
     $result = new Result($filename);
     $n = 0;
     $lcom = new LackOfCohesionOfMethods();
     foreach ($rOOP->getClasses() as $class) {
         $r = $lcom->calculate($class);
         $n += $r->getLcom();
     }
     $result->setLcom($n);
     return $result;
 }
 /**
  * Calculate Lack of cohesion of methods (LCOM)
  *
  *      We have choose the LCOM4 extension (Hitz and Montazeri version)
  *
  * @param ReflectedClass $class
  * @return Result
  */
 public function calculate(ReflectedClass $class)
 {
     $result = new Result();
     $lcom = 0;
     $methodsToInspect = $class->getMethods();
     $toSkip = array();
     foreach ($methodsToInspect as $method) {
         if (in_array($method->getName(), $toSkip)) {
             continue;
         }
         $linked = $this->getLinkedMethods($class, $method, $toSkip);
         $toSkip = array_merge($toSkip, $linked);
         $lcom++;
     }
     $result->setLcom($lcom);
     return $result;
 }