for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This software package is licensed under `AGPL, Commercial` license[s].
*
* @package maslosoft/zamm
* @license AGPL, Commercial
* @copyright Copyright (c) Peter Maselkowski <[email protected]>
*/
namespace Maslosoft\Zamm;
use DirectoryIterator;
use ReflectionClass;
use ReflectionProperty;
* Iterator
* @author Piotr Maselkowski <pmaselkowski at gmail.com>
class Iterator
{
* Iterate over classes in same folder.
* @param string $class
* @return string[]
public static function ns($class)
$info = new ReflectionClass($class);
$path = dirname($info->getFileName());
$ns = $info->getNamespaceName();
$classNames = [];
foreach (new DirectoryIterator($path) as $fileInfo)
$name = $fileInfo->getFilename();
// Only files
if (!$fileInfo->isFile())
continue;
}
// Only php
if (!preg_match('~\.php$~', $name))
$classNames[] = sprintf('%s\%s', $ns, basename($name, '.php'));
sort($classNames);
return $classNames;
* Iterate over *public* class methods
public static function methods($class)
$methods = [];
foreach ($info->getMethods(ReflectionProperty::IS_PUBLIC) as $method)
$methods[] = $method->name;
return $methods;