src/Entity/Organization.php
public function getEmployee($userOrId)
    {
        $employees = $this->getEmployees();
        $userId    = $userOrId instanceof \Auth\Entity\UserInterface ? $userOrId->getId() : $userOrId;

        foreach ($employees as $employee) {
            if ($employee->getUser()->getId() == $userId) {
                return $employee;
            }
        }

        return null;
    }
public function getEmployee($userOrId)
    {
        $employees = $this->getEmployees();
        $userId    = $userOrId instanceof \Auth\Entity\UserInterface ? $userOrId->getId() : $userOrId;

        foreach ($employees as $employee) {
            if ($employee->getUser()->getId() == $userId) {
                return $employee;
            }
        }

        return null;
    }
Gets an employee by User or ID.

@param UserInterface|string $userOrId

@return mixed|null