*/ public function streamAll( PageSize $pageSize = new PageSize(), ?EmployeeSorter $sorter = null, ): StreamOf { return new StreamOf( fn (Pagination $pagination) => $this->getAll($pagination, $sorter), $pageSize, ); } /** @return StreamOf */ public function streamAllSince( \DateTimeInterface $since, PageSize $pageSize = new PageSize(), \SortDirection $sortDirection = \SortDirection::Descending, ): StreamOf { return new StreamOf( fn (Pagination $pagination) => $this->getAllSince($pagination, $since, $sortDirection), $pageSize, ); } /** * @param SiteId[]|SiteId $sites * @return StreamOf */ public function streamAllOfSitesSince( array | SiteId $sites, \DateTimeInterface $since, PageSize $pageSize = new PageSize(), \SortDirection $sortDirection = \SortDirection::Descending, ): StreamOf { return new StreamOf( fn (Pagination $pagination) => $this->getAllOfSitesSince($pagination, $sites, $since, $sortDirection), $pageSize, ); } /** * @param SiteId[]|SiteId $sites * @return StreamOf */ public function streamAllOfSites( array | SiteId $sites, PageSize $pageSize = new PageSize(), ?EmployeeSorter $sorter = null, ): StreamOf { return new StreamOf( fn (Pagination $pagination) => $this->getAllOfSites($pagination, $sites, $sorter), $pageSize, ); } /** @return PageOf|ApiError */ public function getAllSince( Pagination $pagination, \DateTimeInterface $since, \SortDirection $sortDirection = \SortDirection::Descending, ): PageOf | ApiError { return $this->employeeRepository->selectAllSince( $pagination, $since, $sortDirection ); } /** @return PageOf|ApiError */ public function getAll( Pagination $pagination, ?EmployeeSorter $sorter = null, ): PageOf | ApiError { return $this->employeeRepository->selectAll( $pagination, $sorter, ); } /** * @param SiteId[]|SiteId $sites * @return PageOf|ApiError */ public function getAllOfSitesSince( Pagination $pagination, array | SiteId $sites, \DateTimeInterface $since, \SortDirection $sortDirection = \SortDirection::Descending, ): PageOf | ApiError { $sites = is_array($sites) ? $sites : [$sites]; if (count($sites) < 1) { throw new \InvalidArgumentException('At least 1 site is required'); } foreach ($sites as $site) { if (! ($site instanceof SiteId)) { throw new \InvalidArgumentException('Expected instance of ' . SiteId::class); } } return $this->employeeRepository->selectAllHavingSitesSince( $pagination, $since, $sites, $sortDirection, ); } /** * @param SiteId[]|SiteId $sites * @return PageOf|ApiError */ public function getAllOfSites( Pagination $pagination, array | SiteId $sites, ?EmployeeSorter $sorter = null, ): PageOf | ApiError { $sites = is_array($sites) ? $sites : [$sites]; if (count($sites) < 1) { throw new \InvalidArgumentException('At least 1 site is required'); } foreach ($sites as $site) { if (! ($site instanceof SiteId)) { throw new \InvalidArgumentException('Expected instance of ' . SiteId::class); } } if ($sorter !== null) { return $this->employeeRepository->selectAllHavingSites( $pagination, $sites, $sorter ); } return $this->employeeRepository->selectAllHavingSites( $pagination, $sites, ); } public function findBy(ArcadiaEmployeeId $id): Employee | null | ApiError { return $this->employeeRepository->find($id); } }