<commit_before><?php

namespace Modularity\Module\Contacts;

class Contacts extends \Modularity\Module
{
    public $slug = 'contacts';
    public $supports = array();

    public function init()
    {
        $this->nameSingular = __('Contacts v2', 'modularity');
        $this->namePlural = __('Contacts v2', 'modularity');
        $this->description = __('Outputs one or more contacts', 'modularity');
    }

    public function data() : array
    {
        $data = get_fields($this->ID);
        $data['contacts'] = $this->prepareContacts($data['contacts']);
        if (!isset($data['columns'])) {
            $data['columns'] = 'grid-md-12';
        }

        return $data;
    }

    /**
     * Prepare the contact data
     * @param  array $contacts
     * @return array
     */
    public function prepareContacts($contacts)
    {

        $retContacts = array();

        foreach ($contacts as &$contact) {
            $info = array(
                'image' => null,
                'first_name' => null,
                'last_name' => null,
                'work_title' => null,
                'administration_unit' => null,
                'email' => null,
                'phone' => null,
                'address' => null,
                'visiting_address' => null,
                'opening_hours' => null
            );

            switch ($contact['acf_fc_layout']) {
                case 'custom':
                    $info = apply_filters('Modularity/mod-contacts/contact-info', array(
                        'image'               => $contact['image'],
                        'first_name'          => $contact['first_name'],
                        'last_name'           => $contact['last_name'],
                        'work_title'          => $contact['work_title'],
                        'administration_unit' => $contact['administration_unit'],
                        'email'               => strtolower($contact['email']),
                        'phone'               => $contact['phone_numbers'],
                        'address'             => $contact['address'],
                        'visiting_address'    => $contact['visiting_address'],
                        'opening_hours'       => $contact['opening_hours'],
                        'other'               => $contact['other']
                    ), $contact, $contact['acf_fc_layout']);
                    break;

                case 'user':
                    $info = apply_filters('Modularity/mod-contacts/contact-info', array(
                        'id'                  => $contact['user']['ID'],
                        'image'               => null,
                        'first_name'          => $contact['user']['user_firstname'],
                        'last_name'           => $contact['user']['user_lastname'],
                        'work_title'          => null,
                        'administration_unit' => null,
                        'email'               => strtolower($contact['user']['user_email']),
                        'phone'               => null,
                        'address'             => null,
                        'visiting_address'    => null,
                        'opening_hours'       => null
                    ), $contact, $contact['acf_fc_layout']);

                    break;
            }

            //Parse thumbnail id's
            $info['thumbnail'] = false;
            if (isset($info['image']) && !empty($info['image']) && is_numeric($info['image']['id'])) {
                $info['thumbnail'] = wp_get_attachment_image_src(
                    $info['image']['id'],
                    apply_filters(
                        'Modularity/image/contact',
                        municipio_to_aspect_ratio('1:1', array(400, 400)),
                        $this->args
                    )
                );
            }

            //Parse directly inputted url:s
            if (isset($info['image']) && filter_var($info['image'], FILTER_VALIDATE_URL) !== false) {
                $info['thumbnail'] = array($info['image'], 250, 250, false);
            }

            //Create full name
            $info['full_name'] = trim($info['first_name'] . ' ' . $info['last_name']);

            $retContacts[] = $info;
        }

        return $retContacts;<commit_msg>Contacts Module Fix: Validate var<commit_after><?php

namespace Modularity\Module\Contacts;

class Contacts extends \Modularity\Module
{
    public $slug = 'contacts';
    public $supports = array();

    public function init()
    {
        $this->nameSingular = __('Contacts v2', 'modularity');
        $this->namePlural = __('Contacts v2', 'modularity');
        $this->description = __('Outputs one or more contacts', 'modularity');
    }

    public function data() : array
    {
        $data = get_fields($this->ID);
        $data['contacts'] = $this->prepareContacts($data['contacts']);
        if (!isset($data['columns'])) {
            $data['columns'] = 'grid-md-12';
        }

        return $data;
    }

    /**
     * Prepare the contact data
     * @param  array $contacts
     * @return array
     */
    public function prepareContacts($contacts)
    {

        $retContacts = array();

        foreach ($contacts as &$contact) {
            $info = array(
                'image' => null,
                'first_name' => null,
                'last_name' => null,
                'work_title' => null,
                'administration_unit' => null,
                'email' => null,
                'phone' => null,
                'address' => null,
                'visiting_address' => null,
                'opening_hours' => null
            );

            switch ($contact['acf_fc_layout']) {
                case 'custom':
                    $info = apply_filters('Modularity/mod-contacts/contact-info', array(
                        'image'               => $contact['image'],
                        'first_name'          => $contact['first_name'],
                        'last_name'           => $contact['last_name'],
                        'work_title'          => $contact['work_title'],
                        'administration_unit' => $contact['administration_unit'],
                        'email'               => strtolower($contact['email']),
                        'phone'               => $contact['phone_numbers'],
                        'address'             => $contact['address'],
                        'visiting_address'    => $contact['visiting_address'],
                        'opening_hours'       => $contact['opening_hours'],
                        'other'               => $contact['other']
                    ), $contact, $contact['acf_fc_layout']);
                    break;

                case 'user':
                    $info = apply_filters('Modularity/mod-contacts/contact-info', array(
                        'id'                  => $contact['user']['ID'],
                        'image'               => null,
                        'first_name'          => $contact['user']['user_firstname'],
                        'last_name'           => $contact['user']['user_lastname'],
                        'work_title'          => null,
                        'administration_unit' => null,
                        'email'               => strtolower($contact['user']['user_email']),
                        'phone'               => null,
                        'address'             => null,
                        'visiting_address'    => null,
                        'opening_hours'       => null
                    ), $contact, $contact['acf_fc_layout']);

                    break;
            }

            //Parse thumbnail id's
            $info['thumbnail'] = false;
            if (isset($info['image']) && !empty($info['image']) && isset($info['image']['id']) && is_numeric($info['image']['id'])) {
                $info['thumbnail'] = wp_get_attachment_image_src(
                    $info['image']['id'],
                    apply_filters(
                        'Modularity/image/contact',
                        municipio_to_aspect_ratio('1:1', array(400, 400)),
                        $this->args
                    )
                );
            }

            //Parse directly inputted url:s
            if (isset($info['image']) && filter_var($info['image'], FILTER_VALIDATE_URL) !== false) {
                $info['thumbnail'] = array($info['image'], 250, 250, false);
            }

            //Create full name
            $info['full_name'] = trim($info['first_name'] . ' ' . $info['last_name']);

            $retContacts[] = $info;
        }

        return $retContacts;
{'fraction_non_alphanumeric': 0.143921164203048, 'fraction_numerical': 0.004125128910278446, 'mean_word_length': 1.2998682476943346, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 79, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1872111', 'n_tokens_mistral': 2306, 'n_tokens_neox': 2128, 'n_words': 382}