<commit_before><?php

namespace Synapse\User;

/**
 * Service for tasks relating to user roles
 */
class RoleService
{
    /**
     * @var UserRolePivotMapper
     */
    protected $userRolePivotMapper;

    /**
     * @param UserRolePivotMapper $userRolePivotMapper
     */
    public function __construct(
        UserRolePivotMapper $userRolePivotMapper
    ) {
        $this->userRolePivotMapper = $userRolePivotMapper;
    }

    /**
     * Add a list of roles to a given user
     *
     * @param UserEntity $user
     * @param array      $roles an array of strings
     */
    public function addRolesForUser(UserEntity $user, array $roles)
    {
        foreach ($roles as $role) {
            $this->userRolePivotMapper->addRoleForUser($user->getId(), $role);
        }
    }
}<commit_msg>#130 - updated add role function in role service to only add one role at a time<commit_after><?php

namespace Synapse\User;

/**
 * Service for tasks relating to user roles
 */
class RoleService
{
    /**
     * @var UserRolePivotMapper
     */
    protected $userRolePivotMapper;

    /**
     * @param UserRolePivotMapper $userRolePivotMapper
     */
    public function __construct(
        UserRolePivotMapper $userRolePivotMapper
    ) {
        $this->userRolePivotMapper = $userRolePivotMapper;
    }

    /**
     * Add a role to a given user
     *
     * @param UserEntity $user
     * @param string     $role name of the role to add
     */
    public function addRoleForUser(UserEntity $user, $role)
    {
        $this->userRolePivotMapper->addRoleForUser($user->getId(), $role);
    }
}
{'fraction_non_alphanumeric': 0.10262828535669587, 'fraction_numerical': 0.0018773466833541927, 'mean_word_length': 2.4912663755458517, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '5264814', 'n_tokens_mistral': 484, 'n_tokens_neox': 480, 'n_words': 124}