<commit_before><?php
/**
* Export
*
* Export files using customisation class of PHPOffice/PhpSpreadsheet
* Location: https://github.com/PHPOffice/PhpSpreadsheet
*
* @package      PHP Library
* @subpackage   phplibrary
* @category     Files
* @author       <NAME> <<EMAIL>>
*/
namespace phplibrary;

use PhpOffice\PhpSpreadsheet\Helper\Sample as Sample;
use PhpOffice\PhpSpreadsheet\IOFactory as IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet as Spreadsheet;

/**
* Export files using customisation class of PHPOffice/PhpSpreadsheet
*/
class Export {
    
    // -------------------------------------------------------------------------
    
    /**
    * File name
    * 
    * @var String
    */
    protected static $file_name = 'file_export';
    
    // -------------------------------------------------------------------------
    
    /**
    * Document properties
    * 
    * @var Array
    */
    protected static $document_properties = array(
        'creator'       => '<NAME>',
        'title'         => 'Office 2007 XLSX Test Document',
        'description'   => 'Test document for Office 2007 XLSX, generated using PHP classes.',
        'keywords'      => 'office 2007 openxml php',
        'category'      => 'Test result file',
    );
    
    // -------------------------------------------------------------------------
    
    /**
    * Available cells
    * 
    * @var Array
    */
    protected static $cells = array(
        '', 
        'A', 
        'B', 
        'C', 
        'D', 
        'E', 
        'F', 
        'G', 
        'H', 
        'I', 
        'J', 
        'K', 
        'L', 
        'M', 
        'N', 
        'O', 
        'P', 
        'Q', 
        'R', 
        'S', 
        'T', 
        'U', 
        'V', 
        'W', 
        'X', 
        'Y', 
        'Z',
    );
    
    // -------------------------------------------------------------------------
    
    /**
    * Available types
    * 
    * @var Array
    */
    protected static $allowed_types = array(
        'xlsx', 
        'xls', 
        'csv', 
        'osp',
    );
    
    // -------------------------------------------------------------------------
    
    /**
    * Export file
    * 
    * @param Array $params
    * 
    * @return void
    */
    public static function export_file($params)
    {
        $head        = isset($params['head']) ? $params['head'] : array();
        $data        = isset($params['data']) ? $params['data'] : array();
        $type        = isset($params['type']) ? $params['type'] : FALSE;
        $file_name   = isset($params['file_name']) ? $params['file_name'] : self::$file_name;
        $creator     = isset($params['document_properties']['creator']) ? $params['document_properties']['creator'] : self::$document_properties['creator'];
        $title       = isset($params['document_properties']['title']) ? $params['document_properties']['title'] : self::$document_properties['title'];
        $description = isset($params['document_properties']['description']) ? $params['document_properties']['description'] : self::$document_properties['description'];
        $keywords    = isset($params['document_properties']['keywords']) ? $params['document_properties']['keywords'] : self::$document_properties['keywords'];
        $category    = isset($params['document_properties']['category']) ? $params['document_properties']['category'] : self::$document_properties['category'];
        
        // Create new Spreadsheet object
        $spreadsheet = new Spreadsheet();

        // Set document properties
        $spreadsheet->getProperties()->setCreator($creator);
        $spreadsheet->getProperties()->setLastModifiedBy($creator);
        $spreadsheet->getProperties()->setTitle($title);
        $spreadsheet->getProperties()->setSubject($title);<commit_msg>Set default type in Export class<commit_after><?php
/**
* Export
*
* Export files using customisation class of PHPOffice/PhpSpreadsheet
* Location: https://github.com/PHPOffice/PhpSpreadsheet
*
* @package      PHP Library
* @subpackage   phplibrary
* @category     Files
* @author       <NAME> <<EMAIL>>
*/
namespace phplibrary;

use PhpOffice\PhpSpreadsheet\Helper\Sample as Sample;
use PhpOffice\PhpSpreadsheet\IOFactory as IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet as Spreadsheet;

/**
* Export files using customisation class of PHPOffice/PhpSpreadsheet
*/
class Export {
    
    // -------------------------------------------------------------------------
    
    /**
    * File name
    * 
    * @var String
    */
    protected static $file_name = 'file_export';
    
    // -------------------------------------------------------------------------
    
    /**
    * Document properties
    * 
    * @var Array
    */
    protected static $document_properties = array(
        'creator'       => '<NAME>',
        'title'         => 'Office 2007 XLSX Test Document',
        'description'   => 'Test document for Office 2007 XLSX, generated using PHP classes.',
        'keywords'      => 'office 2007 openxml php',
        'category'      => 'Test result file',
    );
    
    // -------------------------------------------------------------------------
    
    /**
    * Available cells
    * 
    * @var Array
    */
    protected static $cells = array(
        '', 
        'A', 
        'B', 
        'C', 
        'D', 
        'E', 
        'F', 
        'G', 
        'H', 
        'I', 
        'J', 
        'K', 
        'L', 
        'M', 
        'N', 
        'O', 
        'P', 
        'Q', 
        'R', 
        'S', 
        'T', 
        'U', 
        'V', 
        'W', 
        'X', 
        'Y', 
        'Z',
    );
    
    // -------------------------------------------------------------------------
    
    /**
    * Available types
    * 
    * @var Array
    */
    protected static $allowed_types = array(
        'xlsx', 
        'xls', 
        'csv', 
        'osp',
    );
    
    // -------------------------------------------------------------------------
    
    /**
    * Export file
    * 
    * @param Array $params
    * 
    * @return void
    */
    public static function export_file($params)
    {
        $head        = isset($params['head']) ? $params['head'] : array();
        $data        = isset($params['data']) ? $params['data'] : array();
        $type        = isset($params['type']) ? $params['type'] : 'xlsx';
        $file_name   = isset($params['file_name']) ? $params['file_name'] : self::$file_name;
        $creator     = isset($params['document_properties']['creator']) ? $params['document_properties']['creator'] : self::$document_properties['creator'];
        $title       = isset($params['document_properties']['title']) ? $params['document_properties']['title'] : self::$document_properties['title'];
        $description = isset($params['document_properties']['description']) ? $params['document_properties']['description'] : self::$document_properties['description'];
        $keywords    = isset($params['document_properties']['keywords']) ? $params['document_properties']['keywords'] : self::$document_properties['keywords'];
        $category    = isset($params['document_properties']['category']) ? $params['document_properties']['category'] : self::$document_properties['category'];
        
        // Create new Spreadsheet object
        $spreadsheet = new Spreadsheet();

        // Set document properties
        $spreadsheet->getProperties()->setCreator($creator);
        $spreadsheet->getProperties()->setLastModifiedBy($creator);
        $spreadsheet->getProperties()->setTitle($title);
        $spreadsheet->getProperties()->setSubject($title);
{'fraction_non_alphanumeric': 0.24057217165149544, 'fraction_numerical': 0.0031209362808842654, 'mean_word_length': 1.619550408719346, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 37, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '3547473', 'n_tokens_mistral': 2140, 'n_tokens_neox': 2032, 'n_words': 394}