function it_does_complain_if_the_number_of_methods_is_too_large(ReflectionClass $sus, Params $params, Reporter $reporter) { $params->getNumberOfMethods()->willReturn(1); $sus->getMethods()->willReturn(['method 1', 'method 2']); $sus->getName()->willReturn('Enormo Class'); $reporter->act($sus, 'Elfiggo\\Brobdingnagian\\Detector\\NumberOfMethods', 'Enormo Class has too many methods (2)', 'Too many methods')->willThrow(TooManyMethodsDetected::class); $this->shouldThrow(TooManyMethodsDetected::class)->duringCheck($sus, $params, $reporter); }
function it_should_analyse_the_number_of_methods_size(SpecificationEvent $specificationEvent, SpecificationNode $specificationNode, Params $params, Reporter $reporter) { $specificationEvent->getSpecification()->willReturn($specificationNode); $specificationNode->getTitle()->willReturn('Elfiggo\\Brobdingnagian\\Detector\\ClassSize'); $this->shouldNotThrow('Elfiggo\\Brobdingnagian\\Exception\\TooManyMethodsDetected'); $params->getClassSize()->willReturn(200); $params->getDependenciesLimit()->willReturn(2); $params->getNumberOfMethods()->willReturn(5); $params->getMethodSize()->willReturn(10); $params->getNumberOfInterfaces()->willReturn(2); $params->getNumberOfTraits()->willReturn(1); $this->analyse($specificationEvent, $params, $reporter); }
/** * @param ReflectionClass $sus * @param Params $params * @param Reporter $reporter */ public function check(ReflectionClass $sus, Params $params, Reporter $reporter) { if (count($sus->getMethods()) > $params->getNumberOfMethods()) { $reporter->act($sus, self::class, "{$sus->getName()} has too many methods (" . count($sus->getMethods()) . ')', 'Too many methods'); } }