<commit_before><?php

namespace OpenConext\EngineBlock\CompatibilityBundle\Http\Response;

use OpenConext\Component\EngineBlockMetadata\ContactPerson;
use OpenConext\Component\EngineBlockMetadata\Entity\IdentityProvider;
use OpenConext\Component\EngineBlockMetadata\Service;
use OpenConext\Component\EngineBlockMetadata\ShibMdScope;

final class JsonHelper
{
    /**
     * @param IdentityProvider $identityProvider
     * @return string
     */
    public static function serializeIdentityProvider(IdentityProvider $identityProvider)
    {
        return json_encode(
            array(
                'entity_id'               => $identityProvider->entityId,
                'organization'            => array(
                    'en' => array(
                        'name'         => $identityProvider->organizationEn->name,
                        'display_name' => $identityProvider->organizationEn->displayName,
                        'url'          => $identityProvider->organizationEn->url,
                    ),
                    'nl' => array(
                        'name'         => $identityProvider->organizationNl->name,
                        'display_name' => $identityProvider->organizationNl->displayName,
                        'url'          => $identityProvider->organizationNl->url,
                    )
                ),
                'single_logout_service'   => array(
                    'binding'  => $identityProvider->singleLogoutService->binding,
                    'location' => $identityProvider->singleLogoutService->location,
                ),
                'contact_persons'         => array_map(
                    function (ContactPerson $contactPerson) {
                        return array(
                            'contact_type'  => $contactPerson->contactType,
                            'email_address' => $contactPerson->emailAddress,
                        );
                    },
                    $identityProvider->contactPersons
                ),
                'description'             => array(
                    'en' => $identityProvider->descriptionEn,
                    'nl' => $identityProvider->descriptionNl
                ),
                'display_name'            => array(
                    'en' => $identityProvider->displayNameEn,
                    'nl' => $identityProvider->displayNameNl,
                ),
                'logo'                    => array(
                    'height' => $identityProvider->logo->height,
                    'width'  => $identityProvider->logo->width,
                    'url'    => $identityProvider->logo->url,
                ),
                'name'                    => array(
                    'en' => $identityProvider->nameEn,
                    'nl' => $identityProvider->nameNl,
                ),
                'shib_md_scopes'          => array_map(
                    function (ShibMdScope $shibMdScope) {
                        return array(
                            'regexp'  => (bool)$shibMdScope->regexp,
                            'allowed' => $shibMdScope->allowed,
                        );
                    },
                    $identityProvider->shibMdScopes
                ),
                'single_sign_on_services' => array_map(
                    function (Service $service) {
                        return array(
                            'binding'  => $service->binding,
                            'location' => $service->location,
                        );
                    },
                    $identityProvider->singleSignOnServices
                ),
            )
        );
    }
}<commit_msg>Corrects codestyle, adds space after typecast<commit_after><?php

namespace OpenConext\EngineBlock\CompatibilityBundle\Http\Response;

use OpenConext\Component\EngineBlockMetadata\ContactPerson;
use OpenConext\Component\EngineBlockMetadata\Entity\IdentityProvider;
use OpenConext\Component\EngineBlockMetadata\Service;
use OpenConext\Component\EngineBlockMetadata\ShibMdScope;

final class JsonHelper
{
    /**
     * @param IdentityProvider $identityProvider
     * @return string
     */
    public static function serializeIdentityProvider(IdentityProvider $identityProvider)
    {
        return json_encode(
            array(
                'entity_id'               => $identityProvider->entityId,
                'organization'            => array(
                    'en' => array(
                        'name'         => $identityProvider->organizationEn->name,
                        'display_name' => $identityProvider->organizationEn->displayName,
                        'url'          => $identityProvider->organizationEn->url,
                    ),
                    'nl' => array(
                        'name'         => $identityProvider->organizationNl->name,
                        'display_name' => $identityProvider->organizationNl->displayName,
                        'url'          => $identityProvider->organizationNl->url,
                    )
                ),
                'single_logout_service'   => array(
                    'binding'  => $identityProvider->singleLogoutService->binding,
                    'location' => $identityProvider->singleLogoutService->location,
                ),
                'contact_persons'         => array_map(
                    function (ContactPerson $contactPerson) {
                        return array(
                            'contact_type'  => $contactPerson->contactType,
                            'email_address' => $contactPerson->emailAddress,
                        );
                    },
                    $identityProvider->contactPersons
                ),
                'description'             => array(
                    'en' => $identityProvider->descriptionEn,
                    'nl' => $identityProvider->descriptionNl
                ),
                'display_name'            => array(
                    'en' => $identityProvider->displayNameEn,
                    'nl' => $identityProvider->displayNameNl,
                ),
                'logo'                    => array(
                    'height' => $identityProvider->logo->height,
                    'width'  => $identityProvider->logo->width,
                    'url'    => $identityProvider->logo->url,
                ),
                'name'                    => array(
                    'en' => $identityProvider->nameEn,
                    'nl' => $identityProvider->nameNl,
                ),
                'shib_md_scopes'          => array_map(
                    function (ShibMdScope $shibMdScope) {
                        return array(
                            'regexp'  => (bool) $shibMdScope->regexp,
                            'allowed' => $shibMdScope->allowed,
                        );
                    },
                    $identityProvider->shibMdScopes
                ),
                'single_sign_on_services' => array_map(
                    function (Service $service) {
                        return array(
                            'binding'  => $service->binding,
                            'location' => $service->location,
                        );
                    },
                    $identityProvider->singleSignOnServices
                ),
            )
        );
    }
}
{'fraction_non_alphanumeric': 0.10114170584284755, 'fraction_numerical': 0.0, 'mean_word_length': 1.189356071743605, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 149, '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': '5713534', 'n_tokens_mistral': 1742, 'n_tokens_neox': 1619, 'n_words': 236}