for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Vine\Queries;
use Vine\Node;
class Count
{
/**
* @param Node $node
* @return int
*/
public function __invoke(Node $node): int
return $this->recursiveCount($node);
}
* Count of all the children nodes
*
private function recursiveCount(Node $node): int
$count = 0;
foreach($node->children() as $child)
$count++; // Childnode itself
$count += $this->recursiveCount($child); // Children of childnode
return $count;