<commit_before><?php

/*
 * This file is part of the 'org.octris.core' package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace org\octris\core\net {
    /**
     * Helper class for temporarly storing request output data.
     *
     * @octdoc      c:net/buffer
     * @copyright   copyright (c) 2012 by <NAME>
     * @author      <NAME> <<EMAIL>>
     */
    class buffer implements \Iterator
    /**/
    {
        /**
         * File handle for managing string stored in memory.
         *
         * @octdoc  p:buffer/$fh
         * @var     resource
         */
        protected $fh;
        /**/
        
        /**
         * Constructor.
         *
         * @octdoc  m:buffer/__construct
         */
        public function __construct()
        /**/
        {
            if (!($this->fh = fopen('php://memory', 'w'))) {
                throw new \Exception("unable to create io storage");
            }
        }
        
        /**
         * Destructor.
         *
         * @octdoc  m:buffer/__destruct
         */
        public function __destruct()
        /**/
        {
            fclose($this->fh);
        }
        
        /**
         * Store data.
         *
         * @octdoc  m:buffer/write
         * @param   resource            $ch             Curl resource handle.
         * @param   string              $data           Data to store.
         */
        public function write($ch, $data)
        /**/
        {
            fputs($this->fh, $data);
        }
        
        /**
         * Return stored data.
         *
         * @octdoc  m:buffer/getContent
         * @return  string                              Stored data.
         */
        public function getContent()
        /**/
        {
            rewind($this->fh);
            
            return stream_get_contents($fh);
        }
    }
}<commit_msg>buffer now extends file class of framework<commit_after><?php

/*
 * This file is part of the 'org.octris.core' package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace org\octris\core\net {
    /**
     * Helper class for temporarly storing request output data.
     *
     * @octdoc      c:net/buffer
     * @copyright   copyright (c) 2012 by <NAME>
     * @author      <NAME> <<EMAIL>>
     */
    class buffer extends \org\octris\core\fs\file
    /**/
    {
        /**
         * Constructor.
         *
         * @octdoc  m:buffer/__construct
         */
        public function __construct()
        /**/
        {
            parent::__construct(
                'php://memory', 
                'w', 
                parent::T_READ_TRIM_NEWLINE | parent::T_STREAM_ITERATOR
            );
        }
    }
}
{'fraction_non_alphanumeric': 0.11802942182689018, 'fraction_numerical': 0.0027369141293191925, 'mean_word_length': 1.2475019215987702, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, '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': '87637', 'n_tokens_mistral': 833, 'n_tokens_neox': 808, 'n_words': 204}