Thruway\Procedure::getNextThruwayRegistration PHP Метод

getNextThruwayRegistration() приватный Метод

    private function getNextThruwayRegistration()
    {
        $congestion = true;
        /* @var $bestRegistration \Thruway\Registration */
        $bestRegistration = $this->registrations[0];
        /* @var $registration \Thruway\Registration */
        foreach ($this->registrations as $registration) {
            if ($registration->getSession()->getPendingCallCount() == 0) {
                $bestRegistration = $registration;
                $congestion = false;
                break;
            }
            if ($registration->getSession()->getPendingCallCount() < $bestRegistration->getSession()->getPendingCallCount()) {
                $bestRegistration = $registration;
            }
        }
        if ($congestion) {
            // there is congestion
            $bestRegistration->getSession()->getRealm()->publishMeta('thruway.metaevent.procedure.congestion', [["name" => $this->getProcedureName()]]);
            return NULL;
        }
        return $bestRegistration;
    }