public function testGetClass() { $this->assertEquals('stdClass', Debugger::getClass('stdClass')); $this->assertEquals(get_called_class(), Debugger::getClass(get_called_class())); $this->assertEquals('Debugger', Debugger::getClass('MD\\Foundation\\Debug\\Debugger', true)); $this->assertEquals('MD\\Foundation\\Tests\\TestFixtures\\Collection', Debugger::getClass(new Collection())); $this->assertEquals('Collection', Debugger::getClass(new Collection(), true)); }
/** * Returns class name for this module. * * @return string */ public function getClass() { if ($this->class) { return $this->class; } $this->class = Debugger::getClass($this); return $this->class; }
/** * Parses arguments of a method call. * * @param array $arguments Arguments. * * @return array */ private function parseCallArguments(array $arguments) { $args = []; foreach ($arguments as $argument) { if (is_object($argument)) { $args[] = '<comment>(object)</comment> ' . StringUtils::truncate(Debugger::getClass($argument), 32, '...', StringUtils::TRUNCATE_MIDDLE); } elseif (is_array($argument)) { $args[] = '<comment>(array)</comment> ' . StringUtils::truncate(json_encode($argument), 32, '...', StringUtils::TRUNCATE_MIDDLE); } elseif (is_string($argument)) { $args[] = sprintf("'%s'", StringUtils::truncate($argument, 32, '...', StringUtils::TRUNCATE_MIDDLE)); } else { $args[] = $argument; } } return implode(', ', $args); }
/** * Returns the name of this kernel - its class name by default. * * @return string */ public function getName() { if (!$this->name) { $this->name = Debugger::getClass($this, true); } return $this->name; }
/** * Returns (basic) information about all registered services. * * @return array */ public function dump() { $services = array(); foreach ($this->services as $name => $definition) { $info = array('name' => $name); $class = $definition->getClass(); if ($class) { $info['class'] = ltrim($this->parametersResolver->resolve($class), NS); } if ($definition instanceof ObjectService) { $info['class'] = Debugger::getClass($definition->getInstance()); } $services[$name] = $info; } foreach ($this->aliases as $alias => $target) { $services[$alias] = array('name' => $alias, 'alias' => $this->resolveServiceName($target)); } return $services; }