<commit_before><?php

/**
 * Fuel is a fast, lightweight, community driven PHP5 framework.
 *
 * @package    Fuel
 * @version    1.0
 * @author     Fuel Development Team
 * @license    MIT License
 * @copyright  2010 - 2011 Fuel Development Team
 * @link       http://fuelphp.com
 */

namespace Hybrid;

/**
 * Hybrid 
 * 
 * A set of class that extends the functionality of FuelPHP without 
 * affecting the standard workflow when the application doesn't actually 
 * utilize Hybrid feature.
 * 
 * @package     Fuel
 * @subpackage  Hybrid
 * @category    Curl
 * @author      <NAME> <<EMAIL>>
 */
class Curl {
    
    /**
     * A shortcode to initiate this class as a new object
     * 
     * @static
     * @access  public
     * @param   string  $uri
     * @param   array   $dataset
     * @return  static 
     */
    public static function factory($uri, $dataset = array())
    {
        $uri_segments   = explode(' ', $uri);
        $type           = 'GET';

        if (in_array(strtoupper($uri_segments[0]), array('DELETE', 'POST', 'PUT', 'GET'))) 
        {
            $uri        = $uri_segments[1];
            $type       = $uri_segments[0];
        }

        $dataset = array_merge(static::query_string($uri), $dataset);

        return new static($uri, $dataset, $type);
    }
    
    /**
     * A shortcode to initiate this class as a new object using GET
     * 
     * @static
     * @access  public
     * @param   string  $uri
     * @param   array   $dataset
     * @return  static 
     */
    public static function get($uri, $dataset)
    {
        $dataset = array_merge(static::query_string($uri), $dataset);
        
        return new static($uri, $dataset, 'GET');
    }
    
    /**
     * A shortcode to initiate this class as a new object using POST
     * 
     * @static
     * @access  public
     * @param   string  $uri
     * @param   array   $dataset
     * @return  static 
     */
    public static function post($uri, $dataset)
    {
        return new static($uri, $dataset, 'POST');
    }
    
    /**
     * A shortcode to initiate this class as a new object using PUT
     * 
     * @static
     * @access  public
     * @param   string  $uri
     * @param   array   $dataset
     * @return  static 
     */
    public static function put($url, $dataset)
    {
        return new static($uri, $dataset, 'PUT');
    }
    
    /**
     * A shortcode to initiate this class as a new object using DELETE
     * 
     * @static
     * @access  public
     * @param   string  $uri
     * @param   array   $dataset
     * @return  static 
     */
    public static function delete($url, $dataset)
    {
        return new static($uri, $dataset, 'DELETE');
    }
    
    /**
     * Generate query string
     * 
     * @static
     * @access  protected
     * @param   string  $uri
     * @return  array 
     */
    protected static function query_string($uri)
    {
        $query_dataset  = array();
        $query_string   = parse_url($uri);

        if (isset($query_string['query'])) 
        {
            $uri        = $query_string['path'];
            parse_str($query_string['query'], $query_dataset);
        }
        
        return $query_dataset;
    }
    
    protected $request_uri      = '';
    protected $adapter          = null;
    protected $request_data     = array();
    protected $request_method   = '';
    
    /**
     * Construct a new object
     * 
     * @access  public
     * @param   string  $uri
     * @param   array   $dataset
     * @param   string  $type 
     */
    public function __construct($uri, $dataset = array(), $type = 'GET')
    {
        $this->request_uri      = $uri;
        $this->request_method   = $type;
        $this->request_data     = $dataset;
        $this->adapter          = curl_init();
    }
    
    /**
     * Set curl options
     * 
     * @access  public
     * @param   mixed   $option
     * @param   string  $value
     * @return  Curl 
     */
    public function set($option, $value = null)
    {
        if (is_array($option))
        {
            foreach ($option as $key => $value)
            {
                curl_setopt($this->adapter, $key, $value);
            }
        }
        elseif (is_string($option) and isset($value))
        {
            curl_setopt($this->adapter, $option, $value);
        }
        
        return $this;
    }
    <commit_msg>Fixed #21: \Hybrid\Curl::set() should be replaced with \Hybrid\Curl::setopt()<commit_after><?php

/**
 * Fuel is a fast, lightweight, community driven PHP5 framework.
 *
 * @package    Fuel
 * @version    1.0
 * @author     Fuel Development Team
 * @license    MIT License
 * @copyright  2010 - 2011 Fuel Development Team
 * @link       http://fuelphp.com
 */

namespace Hybrid;

/**
 * Hybrid 
 * 
 * A set of class that extends the functionality of FuelPHP without 
 * affecting the standard workflow when the application doesn't actually 
 * utilize Hybrid feature.
 * 
 * @package     Fuel
 * @subpackage  Hybrid
 * @category    Curl
 * @author      <NAME> <<EMAIL>>
 */
class Curl {
    
    /**
     * A shortcode to initiate this class as a new object
     * 
     * @static
     * @access  public
     * @param   string  $uri
     * @param   array   $dataset
     * @return  static 
     */
    public static function factory($uri, $dataset = array())
    {
        $uri_segments   = explode(' ', $uri);
        $type           = 'GET';

        if (in_array(strtoupper($uri_segments[0]), array('DELETE', 'POST', 'PUT', 'GET'))) 
        {
            $uri        = $uri_segments[1];
            $type       = $uri_segments[0];
        }

        $dataset = array_merge(static::query_string($uri), $dataset);

        return new static($uri, $dataset, $type);
    }
    
    /**
     * A shortcode to initiate this class as a new object using GET
     * 
     * @static
     * @access  public
     * @param   string  $uri
     * @param   array   $dataset
     * @return  static 
     */
    public static function get($uri, $dataset)
    {
        $dataset = array_merge(static::query_string($uri), $dataset);
        
        return new static($uri, $dataset, 'GET');
    }
    
    /**
     * A shortcode to initiate this class as a new object using POST
     * 
     * @static
     * @access  public
     * @param   string  $uri
     * @param   array   $dataset
     * @return  static 
     */
    public static function post($uri, $dataset)
    {
        return new static($uri, $dataset, 'POST');
    }
    
    /**
     * A shortcode to initiate this class as a new object using PUT
     * 
     * @static
     * @access  public
     * @param   string  $uri
     * @param   array   $dataset
     * @return  static 
     */
    public static function put($url, $dataset)
    {
        return new static($uri, $dataset, 'PUT');
    }
    
    /**
     * A shortcode to initiate this class as a new object using DELETE
     * 
     * @static
     * @access  public
     * @param   string  $uri
     * @param   array   $dataset
     * @return  static 
     */
    public static function delete($url, $dataset)
    {
        return new static($uri, $dataset, 'DELETE');
    }
    
    /**
     * Generate query string
     * 
     * @static
     * @access  protected
     * @param   string  $uri
     * @return  array 
     */
    protected static function query_string($uri)
    {
        $query_dataset  = array();
        $query_string   = parse_url($uri);

        if (isset($query_string['query'])) 
        {
            $uri        = $query_string['path'];
            parse_str($query_string['query'], $query_dataset);
        }
        
        return $query_dataset;
    }
    
    protected $request_uri      = '';
    protected $adapter          = null;
    protected $request_data     = array();
    protected $request_method   = '';
    
    /**
     * Construct a new object
     * 
     * @access  public
     * @param   string  $uri
     * @param   array   $dataset
     * @param   string  $type 
     */
    public function __construct($uri, $dataset = array(), $type = 'GET')
    {
        $this->request_uri      = $uri;
        $this->request_method   = $type;
        $this->request_data     = $dataset;
        $this->adapter          = curl_init();
    }
    
    /**
     * Set curl options
     * 
     * @access  public
     * @param   mixed   $option
     * @param   string  $value
     * @return  Curl 
     */
    public function setopt($option, $value = null)
    {
        if (is_array($option))
        {
            foreach ($option as $key => $value)
            {
                curl_setopt($this->adapter, $key, $value);
            }
        }
        elseif (is_string($option) and isset($value))
        {
            curl_setopt($this->adapter, $option, $value);
        }
        
        return $this;
    }
    
{'fraction_non_alphanumeric': 0.12027530181654067, 'fraction_numerical': 0.0033848584000902627, 'mean_word_length': 1.7107033639143732, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1950103', 'n_tokens_mistral': 2705, 'n_tokens_neox': 2607, 'n_words': 717}