<commit_before><?php
class EngineBlock_SocialData_FieldMapper
{
    // Key: ldap, value: opensocial
    protected $_l2oMap = array(
        "collabpersonid" => "id" , 
        "displayName" => array(
            "displayname",
            "nickname"
        ) ,
        "mail"      => "emails" ,
        "givenName" => "name"
    );
    
    protected $_o2lMap = array(
        "id"            => "collabpersonid" ,
        "nickname"      => "displayName" ,
        "displayname"   => "displayName" ,
        "emails"        => "mail" ,
        "name"          => "givenName"
    );

    protected $_oMultiValueAttributes = array(
        'emails'
    );

    /**
     * 
     * @param $directoryItem
     */
    public function socialToLdapAttributes($attributes)
    {
        $result = array();
        foreach ($attributes as $socialAttr) {
            $socialAttr = strtolower($socialAttr);
            if (isset($this->_o2lMap[$socialAttr])) {
                $result[] = $this->_o2lMap[$socialAttr];
            } else {
                // We have no mapping for this social field, use the key as-is (useful if userregistry contains
                // custom stuff)
                $result[] = $socialAttr;
            }
        }
        return $result;
    }

    public function ldapToSocialData($data, $socialAttrs = array())
    {
        $result = array();
        if (count($socialAttrs)) {
            foreach ($socialAttrs as $socialAttr) {
                $socialAttr = strtolower($socialAttr);
                if (isset($this->_o2lMap[$socialAttr])) {
                    $ldapAttr = $this->_o2lMap[$socialAttr];
                    if (isset($data[$ldapAttr])) {
                        $result[$socialAttr] = $this->_pack($data[$ldapAttr], $socialAttr);
                    } else {    // if there's no opensocial equivalent for this field
                    // assume this is stuff we're not allowed to share
                    // so do not include it in the result.
                    }
                }
            }
        } else {
            foreach ($data as $ldapAttr => $value) {
                $ldapAttr = strtolower($ldapAttr);<commit_msg>Removed strtolowers, because spec demands camelCasing<commit_after><?php
class EngineBlock_SocialData_FieldMapper
{
    // Key: ldap, value: opensocial
    protected $_l2oMap = array(
        "collabpersonid" => "id" , 
        "displayname" => array(
            "displayName",
            "nickName"
        ) ,
        "mail"      => "emails" ,
        "givenname" => "name"
    );
    
    protected $_o2lMap = array(
        "id"            => "collabpersonid" ,
        "nickname"      => "displayname" ,
        "displayName"   => "displayname" ,
        "emails"        => "mail" ,
        "name"          => "givenname"
    );

    protected $_oMultiValueAttributes = array(
        'emails'
    );

    /**
     * 
     * @param $directoryItem
     */
    public function socialToLdapAttributes($attributes)
    {
        $result = array();
        foreach ($attributes as $socialAttr) {
            if (isset($this->_o2lMap[$socialAttr])) {
                $result[] = $this->_o2lMap[$socialAttr];
            } else {
                // We have no mapping for this social field, use the key as-is (useful if userregistry contains
                // custom stuff)
                $result[] = $socialAttr;
            }
        }
        return $result;
    }

    public function ldapToSocialData($data, $socialAttrs = array())
    {
        $result = array();
        if (count($socialAttrs)) {
            foreach ($socialAttrs as $socialAttr) {
                if (isset($this->_o2lMap[$socialAttr])) {
                    $ldapAttr = $this->_o2lMap[$socialAttr];
                    if (isset($data[$ldapAttr])) {
                        $result[$socialAttr] = $this->_pack($data[$ldapAttr], $socialAttr);
                    } else {    // if there's no opensocial equivalent for this field
                    // assume this is stuff we're not allowed to share
                    // so do not include it in the result.
                    }
                }
            }
        } else {
            foreach ($data as $ldapAttr => $value) {
{'fraction_non_alphanumeric': 0.12485248996931791, 'fraction_numerical': 0.0028321925890960587, 'mean_word_length': 1.5211183819155265, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, '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': '4034269', 'n_tokens_mistral': 1199, 'n_tokens_neox': 1151, 'n_words': 268}