<commit_before><?php

namespace BjyAuthorize\Provider\Identity;

use BjyAuthorize\Acl\Role;
use Zend\Db\Adapter\Adapter;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\Sql\Where;
use Zend\Db\Sql\Sql;

class ZfcUserZendDb implements ProviderInterface
{
    protected $userService;
    protected $defaultRole;

    public function __construct(Adapter $adapter)
    {
        $this->adapter = $adapter;
    }

    public function getIdentityRoles()
    {
        $authService = $this->userService->getAuthService();

        if (!$authService->hasIdentity()) {
            // get default/guest role
            return $this->getDefaultRole();
        } else {
            // get roles associated with the logged in user
            $sql = new Sql($this->adapter);
            $select = $sql->select()
                ->from('user_role_linker');

            $where = new Where();
            $where->equalTo('user_id', $authService->getIdentity()->getUserId());

            $statement = $sql->prepareStatementForSqlObject($select->where($where));

            $resultSet = new ResultSet;
            $results = $resultSet->setDataSource($statement->execute())->toArray();

            $roles = array();
            foreach ($results as $i) {
                $roles[] = $i['role_id'];
            }

            return $roles;
        }
    }

    public function getUserService()
    {
        return $this->userService;
    }

    public function setUserService($userService)
    {
        $this->userService = $userService;
        return $this;
    }

    public function getDefaultRole()
    {<commit_msg>update to match zfcuser<commit_after><?php

namespace BjyAuthorize\Provider\Identity;

use BjyAuthorize\Acl\Role;
use Zend\Db\Adapter\Adapter;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\Sql\Where;
use Zend\Db\Sql\Sql;

class ZfcUserZendDb implements ProviderInterface
{
    protected $userService;
    protected $defaultRole;

    public function __construct(Adapter $adapter)
    {
        $this->adapter = $adapter;
    }

    public function getIdentityRoles()
    {
        $authService = $this->userService->getAuthService();

        if (!$authService->hasIdentity()) {
            // get default/guest role
            return $this->getDefaultRole();
        } else {
            // get roles associated with the logged in user
            $sql = new Sql($this->adapter);
            $select = $sql->select()
                ->from('user_role_linker');

            $where = new Where();
            $where->equalTo('user_id', $authService->getIdentity()->getId());

            $statement = $sql->prepareStatementForSqlObject($select->where($where));

            $results = $statement->execute();

            $roles = array();
            foreach ($results as $i) {
                $roles[] = $i['role_id'];
            }

            return $roles;
        }
    }

    public function getUserService()
    {
        return $this->userService;
    }

    public function setUserService($userService)
    {
        $this->userService = $userService;
        return $this;
    }

    public function getDefaultRole()
    {
{'fraction_non_alphanumeric': 0.12746972594008923, 'fraction_numerical': 0.0, 'mean_word_length': 2.183569979716024, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, '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': '6197487', 'n_tokens_mistral': 895, 'n_tokens_neox': 862, 'n_words': 182}