<commit_before><?php
/**
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to <EMAIL> so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade your module to newer
 * versions in the future.
 *
 * @author    MyFlyingBox <<EMAIL>>
 * @copyright 2016 MyFlyingBox
 *
 * @version   1.0
 *
 * @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

class LceService extends ObjectModel
{
    public $id_service;
    public $id_carrier;
    public $carrier_code;
    public $code;
    public $name;
    public $pickup_available;
    public $dropoff_available;
    public $relay_delivery;
    public $tracking_url;
    public $date_add;
    public $date_upd;

    public static $definition = array(
        'table' => 'lce_services',
        'primary' => 'id_service',
        'multilang' => false,
        'fields' => array(
            'id_carrier' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
            'carrier_code' => array('type' => self::TYPE_STRING),
            'code' => array('type' => self::TYPE_STRING),
            'name' => array('type' => self::TYPE_STRING),
            'pickup_available' => array('type' => self::TYPE_BOOL),
            'dropoff_available' => array('type' => self::TYPE_BOOL),
            'relay_delivery' => array('type' => self::TYPE_BOOL),
            'tracking_url' => array('type' => self::TYPE_STRING),
            'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
            'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
        ),
        'associations' => array(
            'carrier' => array('type' => self::HAS_ONE, 'field' => 'id_carrier', 'object' => 'Carrier'),
        ),
    );

    public static function findByCarrierId($id_carrier)
    {
        $sql = 'SELECT * FROM '._DB_PREFIX_.'lce_services as s
                WHERE s.`id_carrier` = '.(int)$id_carrier;
        $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
        $service = new self((int) $row['id_service']);

        return $service;
    }

    public static function findByCode($service_code)
    {
        $sql = 'SELECT * FROM '._DB_PREFIX_.'lce_services as s
                WHERE s.`code` = "'.$service_code.'"';
        $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
        if ($row) {
            $service = new self((int) $row['id_service']);
        } else {
            $service = false;
        }
        return $service;
    }

    public static function findAll()
    {
        $sql = 'SELECT * FROM '._DB_PREFIX_.'lce_services as s';
        $collection = array();
        if ($rows = Db:: getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql)) {
            foreach ($rows as $row) {
                $collection[] = new self((int) $row['id_service']);
            }
        }
        return $collection;
    }

    public function carrierName()
    {
        if (Tools::strlen($this->carrier_code) > 4) {
            return ucfirst($this->carrier_code);
        } else {
            return strtoupper($this->carrier_code);
        }
    }

    public function logoFileName()
    {
        if (!empty($this->carrier_code)) {
            return $this->carrier_code.'.png';
        } else {
            return 'myflyingbox.png';
        }
    }

    public function getCarrier()
    {
        $carrier = new Carrier((int)$this->id_carrier);
        return $carrier;
    }<commit_msg>Using Prestashop internal wrapper for strtoupper and ucfirst<commit_after><?php
/**
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to <EMAIL> so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade your module to newer
 * versions in the future.
 *
 * @author    MyFlyingBox <<EMAIL>>
 * @copyright 2016 MyFlyingBox
 *
 * @version   1.0
 *
 * @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

class LceService extends ObjectModel
{
    public $id_service;
    public $id_carrier;
    public $carrier_code;
    public $code;
    public $name;
    public $pickup_available;
    public $dropoff_available;
    public $relay_delivery;
    public $tracking_url;
    public $date_add;
    public $date_upd;

    public static $definition = array(
        'table' => 'lce_services',
        'primary' => 'id_service',
        'multilang' => false,
        'fields' => array(
            'id_carrier' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
            'carrier_code' => array('type' => self::TYPE_STRING),
            'code' => array('type' => self::TYPE_STRING),
            'name' => array('type' => self::TYPE_STRING),
            'pickup_available' => array('type' => self::TYPE_BOOL),
            'dropoff_available' => array('type' => self::TYPE_BOOL),
            'relay_delivery' => array('type' => self::TYPE_BOOL),
            'tracking_url' => array('type' => self::TYPE_STRING),
            'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
            'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
        ),
        'associations' => array(
            'carrier' => array('type' => self::HAS_ONE, 'field' => 'id_carrier', 'object' => 'Carrier'),
        ),
    );

    public static function findByCarrierId($id_carrier)
    {
        $sql = 'SELECT * FROM '._DB_PREFIX_.'lce_services as s
                WHERE s.`id_carrier` = '.(int)$id_carrier;
        $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
        $service = new self((int) $row['id_service']);

        return $service;
    }

    public static function findByCode($service_code)
    {
        $sql = 'SELECT * FROM '._DB_PREFIX_.'lce_services as s
                WHERE s.`code` = "'.$service_code.'"';
        $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
        if ($row) {
            $service = new self((int) $row['id_service']);
        } else {
            $service = false;
        }
        return $service;
    }

    public static function findAll()
    {
        $sql = 'SELECT * FROM '._DB_PREFIX_.'lce_services as s';
        $collection = array();
        if ($rows = Db:: getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql)) {
            foreach ($rows as $row) {
                $collection[] = new self((int) $row['id_service']);
            }
        }
        return $collection;
    }

    public function carrierName()
    {
        if (Tools::strlen($this->carrier_code) > 4) {
            return Tools::ucfirst($this->carrier_code);
        } else {
            return Tools::strtoupper($this->carrier_code);
        }
    }

    public function logoFileName()
    {
        if (!empty($this->carrier_code)) {
            return $this->carrier_code.'.png';
        } else {
            return 'myflyingbox.png';
        }
    }

    public function getCarrier()
    {
        $carrier = new Carrier((int)$this->id_carrier);
        return $carrier;
    }
{'fraction_non_alphanumeric': 0.1447859071621448, 'fraction_numerical': 0.0038575286100038576, 'mean_word_length': 2.426431718061674, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 95, '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': '4514717', 'n_tokens_mistral': 2462, 'n_tokens_neox': 2374, 'n_words': 595}