<commit_before><?php
/**
 * User
 */

namespace BlueRidge\Documents;

use \Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;

/** 
 * @ODM\Document(collection="Users",repositoryClass="\BlueRidge\Documents\UserRepository") 
 */
class User
{
    /**
     * User Id
     * @var string
     * @ODM\Id
     */

    protected $id;
    /**
     * Name
     * @var string
     * @ODM\String   
     */
    protected $name;

    /**
     * First Name
     * @var string
     * @ODM\String
     */
    protected $firstName;

    /**
     * Last Name
     * @var string
     * @ODM\String
     */
    protected $lastName;

    /**
     * Email
     * @var string
     * @ODM\String
     */
    protected $email;

    /**
     * Url
     * @var string
     * @ODM\String
     */
    protected $url;

    /**
     * Avatar
     * @var string
     * @ODM\String
     */
    protected $avatar;

    /**
     * Key
     * @var string
     * @ODM\String
     */
    protected $key;

    /**
     * Profile
     * @var Array
     * @ODM\Hash
     */
    protected $profile = array();

    /**
     * Projects
     * @var Array
     * @ODM\Hash
     */
    protected $projects = array();

    /**
     * Subscription
     * @var Array
     * @ODM\Hash
     */
    protected $subscription = array();


    /**
     * Providers
     * @var Array
     * @ODM\Hash
     */
    protected $providers;

    /**
     * Getter
     */
    public function __get($property)
    {
        if (property_exists($this, $property)) {
            return $this->$property;
        }
    }
    
    /**
     * Setter
     */
    public function __set($property, $value)
    {
        if (property_exists($this, $property)) {
            $this->$property = $value;
        }
        return $this;
    }

    /**
     * Set Properties
     * @return Object
     */ 
    public function setProperties(Array $properties)
    {
        foreach($properties as $property => $value){            
            if (property_exists($this, $property)) {
                $this->$property = $value;
            }
        }
        return $this;
    }

    /**
     * Set Subscription 
     */
    public function initNewSubscriber($service)
    {
        \Stripe::setApiKey($service['secret_key']);
        $customer = \Stripe_Customer::create(['description' => $this->name,'email' =>$this->email,'plan'=>'br-free']);

        $this->subscription=[
        'customer_id'=>$customer->id,
        'plan'=>['id'=>$customer->subscription->plan->id,'name'=>$customer->subscription->plan->name],
        'card'=>'',
        'status'=>$customer->subscription->status
        ];

        return $this;
    }

    /**
     * Update Profile
     */
    public function updateProfile($segment,$properties)
    {
        try{
            $this->profile[$segment]= $properties;
            return true;
        }catch(\Exception $error){
            \error_log($error->getMessage());
            return;
        }
    }

    /**
     * To Array
     * @return Array
     */
    public function toArray()
    {
        $properties = ['name','firstName','lastName','email','url','avatar','subscription'];

        $item=array();

        foreach ($this as $property => $value)
        {
            if (in_array($property, $properties))
            {               
                $item[$property]=$value;                                
            }
        }
        return $item;
    }
}<commit_msg>-n  getters / setters<commit_after><?php
/**
 * User
 */

namespace BlueRidge\Documents;

use \Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;

/** 
 * @ODM\Document(collection="Users",repositoryClass="\BlueRidge\Documents\UserRepository") 
 */
class User
{
    /**
     * User Id
     * @var string
     * @ODM\Id
     */

    protected $id;
    /**
     * Name
     * @var string
     * @ODM\String   
     */
    protected $name;

    /**
     * First Name
     * @var string
     * @ODM\String
     */
    protected $firstName;

    /**
     * Last Name
     * @var string
     * @ODM\String
     */
    protected $lastName;

    /**
     * Email
     * @var string
     * @ODM\String
     */
    protected $email;

    /**
     * Url
     * @var string
     * @ODM\String
     */
    protected $url;

    /**
     * Avatar
     * @var string
     * @ODM\String
     */
    protected $avatar;

    /**
     * Key
     * @var string
     * @ODM\String
     */
    protected $key;

    /**
     * Profile
     * @var Array
     * @ODM\Hash
     */
    protected $profile = array();

    /**
     * Projects
     * @var Array
     * @ODM\Hash
     */
    protected $projects = array();

    /**
     * Subscription
     * @var Array
     * @ODM\Hash
     */
    protected $subscription = array();

    /**
     * Providers
     * @var Array
     * @ODM\Hash
     */
    protected $providers;

    /**
     * Set Properties
     * @return Object
     */ 
    public function setProperties(Array $properties)
    {
        foreach($properties as $property => $value){            
            if (property_exists($this, $property)) {
                $this->$property = $value;
            }
        }
        return $this;
    }

    /**
     * Set Subscription 
     */
    public function initNewSubscriber($service)
    {
        \Stripe::setApiKey($service['secret_key']);
        $customer = \Stripe_Customer::create(['description' => $this->name,'email' =>$this->email,'plan'=>'br-free']);

        $this->subscription=[
        'customer_id'=>$customer->id,
        'plan'=>['id'=>$customer->subscription->plan->id,'name'=>$customer->subscription->plan->name],
        'card'=>'',
        'status'=>$customer->subscription->status
        ];

        return $this;
    }

    /**
     * Update Profile
     */
    public function updateProfile($segment,$properties)
    {
        try{
            $this->profile[$segment]= $properties;
            return true;
        }catch(\Exception $error){
            \error_log($error->getMessage());
            return;
        }
    }

    /**
     * To Array
     * @return Array
     */
    public function toArray()
    {
        $properties = ['name','firstName','lastName','email','url','avatar','subscription'];

        $item=array();

        foreach ($this as $property => $value)
        {
            if (in_array($property, $properties))
            {               
                $item[$property]=$value;                                
            }
        }
        return $item;
    }

    /**
     * Fetch Projects
     */
    protected function fetchProjects()
    {
        $projects=array();

        foreach($this->projects as $key => $project){
            
            $selected = (in_array($project['id'], $this->profile['projects']))?true:false;
            $item=$project;
            $item['selected']=$selected;    
            unset(              
                $item['archived'],
                $item['created_at'],
                $item['updated_at'],
                $item['last_event_at'],
                $item['starred']
                );

            $projects[]=$item;
        }
        return $projects;
    }

    /**
     * Getter
     */
    public function __get($property)
    {
        if (property_exists($this, $property)) {

            switch($property)
            {
                case 'accounts':
                $data= $this->profile['accounts']['basecamp'];
                break;
                case 'projects':
                $data = $this->fetchProjects();
                break;
                default:
                $data = $this->$property;

            }       
            return $data;           
        }
    }
    
    /**
     * Setter
     */
    public function __set($property, $value)
    {
        if (property_exists($this, $property)) {
            $this->$property = $value;
        }
        return $this;
    }
}
{'fraction_non_alphanumeric': 0.15244134432466708, 'fraction_numerical': 0.0, 'mean_word_length': 1.4528771384136858, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 64, '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': '6793439', 'n_tokens_mistral': 2347, 'n_tokens_neox': 2284, 'n_words': 402}