function it_does_complain_if_the_number_of_interfaces_is_too_large(ReflectionClass $sus, Params $params, Reporter $reporter) { $params->getNumberOfInterfaces()->willReturn(self::DEFAULT_NUMBER_OF_INTERFACES); $sus->getInterfaces()->willReturn(['interface 1', 'interface 2', 'interface 3', 'interface 4']); $sus->getName()->willReturn('Enormo Class'); $reporter->act($sus, 'Elfiggo\\Brobdingnagian\\Detector\\NumberOfInterfaces', 'Enormo Class has too many interfaces (4)', 'Too many interfaces')->willThrow(TooManyInterfacesDetected::class); $this->shouldThrow(TooManyInterfacesDetected::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 $param * @param Reporter $reporter */ public function check(ReflectionClass $sus, Params $param, Reporter $reporter) { if (count($sus->getInterfaces()) > $param->getNumberOfInterfaces()) { $reporter->act($sus, self::class, "{$sus->getName()} has too many interfaces (" . count($sus->getInterfaces()) . ')', 'Too many interfaces'); } }