<commit_before><?php

namespace OpenConext\EngineBlock\Service;

use OpenConext\Component\EngineBlockMetadata\Entity\IdentityProvider;
use OpenConext\Component\EngineBlockMetadata\Entity\ServiceProvider;
use OpenConext\Component\EngineBlockMetadata\MetadataRepository\EntityNotFoundException;
use OpenConext\Component\EngineBlockMetadata\MetadataRepository\MetadataRepositoryInterface;
use OpenConext\Value\Saml\EntityId;

final class MetadataService
{
    /**
     * @var MetadataRepositoryInterface
     */
    private $metadataRepository;

    public function __construct(MetadataRepositoryInterface $metadataRepository)
    {
        $this->metadataRepository = $metadataRepository;
    }

    /**
     * @param EntityId $entityId
     * @return null|IdentityProvider
     */
    public function findIdentityProvider(EntityId $entityId)
    {
        try {
            $identityProvider = $this->metadataRepository->fetchIdentityProviderByEntityId($entityId->getEntityId());
        } catch (EntityNotFoundException $e) {
            return null;
        }

        return $identityProvider;
    }

    /**
     * @param EntityId $entityId
     * @return null|ServiceProvider
     */
    public function findServiceProvider(EntityId $entityId)
    {
        try {
            $serviceProvider = $this->metadataRepository->fetchServiceProviderByEntityId($entityId->getEntityId());
        } catch (EntityNotFoundException $e) {
            return null;
        }

        return $serviceProvider;
    }
}
<commit_msg>Use MetadataService to find ARP for ServiceProviders<commit_after><?php

namespace OpenConext\EngineBlock\Service;

use OpenConext\Component\EngineBlockMetadata\AttributeReleasePolicy;
use OpenConext\Component\EngineBlockMetadata\Entity\IdentityProvider;
use OpenConext\Component\EngineBlockMetadata\Entity\ServiceProvider;
use OpenConext\Component\EngineBlockMetadata\MetadataRepository\EntityNotFoundException;
use OpenConext\Component\EngineBlockMetadata\MetadataRepository\MetadataRepositoryInterface;
use OpenConext\Value\Saml\EntityId;

final class MetadataService
{
    /**
     * @var MetadataRepositoryInterface
     */
    private $metadataRepository;

    public function __construct(MetadataRepositoryInterface $metadataRepository)
    {
        $this->metadataRepository = $metadataRepository;
    }

    /**
     * @param EntityId $entityId
     * @return null|IdentityProvider
     */
    public function findIdentityProvider(EntityId $entityId)
    {
        try {
            $identityProvider = $this->metadataRepository->fetchIdentityProviderByEntityId($entityId->getEntityId());
        } catch (EntityNotFoundException $e) {
            return null;
        }

        return $identityProvider;
    }

    /**
     * @param EntityId $entityId
     * @return null|ServiceProvider
     */
    public function findServiceProvider(EntityId $entityId)
    {
        try {
            $serviceProvider = $this->metadataRepository->fetchServiceProviderByEntityId($entityId->getEntityId());
        } catch (EntityNotFoundException $e) {
            return null;
        }

        return $serviceProvider;
    }

    /**
     * @param ServiceProvider $serviceProvider
     * @return null|AttributeReleasePolicy
     */
    public function findArpFor(ServiceProvider $serviceProvider)
    {
        return $this->metadataRepository->fetchServiceProviderArp($serviceProvider);
    }
}

{'fraction_non_alphanumeric': 0.0880889669300556, 'fraction_numerical': 0.0, 'mean_word_length': 3.444733420026008, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2556027', 'n_tokens_mistral': 873, 'n_tokens_neox': 863, 'n_words': 147}