<?php
require_once 'VisitorInterface.php';
require_once 
'OrganizationEntryAbstract.php';

class 
CountVisitor implements VisitorInterface
{
    private 
$_groupCount    0;
    private 
$_employeeCount 0;

    public function 
visit(OrganizationEntryAbstract $entry)
    {
        if (
get_class($entry) === 'Group') {
            
$this->_groupCount++;
        } else {
            
$this->_employeeCount++;
        }

        foreach (
$entry->getChildren() as $child) {
            
$child->accept($this);
        }
    }

    public function 
getGroupCount()
    {
        return 
$this->_groupCount;
    }

    public function 
getEmployeeCount()
    {
        return 
$this->_employeeCount;
    }
}