*/ public function getThirdPartiesAssociated(AccompanyingPeriod $period): array { $thirdParties = []; foreach ( $period ->getResources()->filter(fn (Resource $resource) => null !== $resource->getThirdParty()) ->map(fn (Resource $resource) => $resource->getThirdParty()) as $thirdParty) { $thirdParties[] = $thirdParty; } if (null !== $requestor = $period->getRequestorThirdParty()) { $thirdParties[] = $requestor; } return array_values( // filter objects to remove duplicates array_filter( $thirdParties, fn ($o, $k) => array_search($o, $thirdParties, true) === $k, ARRAY_FILTER_USE_BOTH ) ); } }