<commit_before><?php

/**
 * Contact
 *
 * @author Team phpManufaktur <<EMAIL>>
 * @link https://kit2.phpmanufaktur.de/FacebookGallery
 * @copyright 2013 <NAME> <<EMAIL>>
 * @license MIT License (MIT) http://www.opensource.org/licenses/MIT
 */

namespace phpManufaktur\Contact\Data\Contact;

use Silex\Application;

class Company
{

    protected $app = null;
    protected static $table_name = null;

    /**
     * Constructor
     *
     * @param Application $app
     */
    public function __construct(Application $app)
    {
        $this->app = $app;
        self::$table_name = FRAMEWORK_TABLE_PREFIX.'contact_company';
    }

    /**
     * Create the COMPANY table
     *
     * @throws \Exception
     */
    public function createTable()
    {
        $table = self::$table_name;
        $SQL = <<<EOD
    CREATE TABLE IF NOT EXISTS `$table` (
        `company_id` INT(11) NOT NULL AUTO_INCREMENT,
        `contact_id` INT(11) NOT NULL DEFAULT '-1',
        `company_name` VARCHAR(128) NOT NULL DEFAULT '',
        `company_department` VARCHAR(128) NOT NULL DEFAULT '',
        `company_additional` VARCHAR(128) NOT NULL DEFAULT '',
        `company_additional_2` VARCHAR(128) NOT NULL DEFAULT '',
        `company_additional_3` VARCHAR(128) NOT NULL DEFAULT '',
        `company_primary_address_id` INT(11) NOT NULL DEFAULT '-1',
        `company_primary_person_id` INT(11) NOT NULL DEFAULT '-1',
        `company_primary_phone_id` INT(11) NOT NULL DEFAULT '-1',
        `company_primary_email_id` INT(11) NOT NULL DEFAULT '-1',
        `company_primary_note_id` INT(11) NOT NULL DEFAULT '-1',
        `company_status` ENUM('ACTIVE', 'LOCKED', 'DELETED') NOT NULL DEFAULT 'ACTIVE',
        `company_timestamp` TIMESTAMP,
        PRIMARY KEY (`company_id`),
        INDEX (`contact_id`)
        )
    COMMENT='The main contact table'
    ENGINE=InnoDB
    AUTO_INCREMENT=1
    DEFAULT CHARSET=utf8
    COLLATE='utf8_general_ci'
EOD;
        try {
            $this->app['db']->query($SQL);
            $this->app['monolog']->addInfo("Created table 'contact_company'", array(__METHOD__, __LINE__));
        } catch (\Doctrine\DBAL\DBALException $e) {
            throw new \Exception($e);
        }
    }

    /**
     * Return a default (empty) PERSON contact record.
     *
     * @return array
     */
    public function getDefaultRecord()
    {
        return array(
            'company_id' => -1,
            'contact_id' => -1,
            'company_name' => '',
            'company_department' => '',
            'company_additional' => '',
            'company_additional_2' => '',<commit_msg>changed contact_id from INDEX to UNIQUE<commit_after><?php

/**
 * Contact
 *
 * @author Team phpManufaktur <<EMAIL>>
 * @link https://kit2.phpmanufaktur.de/FacebookGallery
 * @copyright 2013 <NAME> <<EMAIL>>
 * @license MIT License (MIT) http://www.opensource.org/licenses/MIT
 */

namespace phpManufaktur\Contact\Data\Contact;

use Silex\Application;

class Company
{

    protected $app = null;
    protected static $table_name = null;

    /**
     * Constructor
     *
     * @param Application $app
     */
    public function __construct(Application $app)
    {
        $this->app = $app;
        self::$table_name = FRAMEWORK_TABLE_PREFIX.'contact_company';
    }

    /**
     * Create the COMPANY table
     *
     * @throws \Exception
     */
    public function createTable()
    {
        $table = self::$table_name;
        $SQL = <<<EOD
    CREATE TABLE IF NOT EXISTS `$table` (
        `company_id` INT(11) NOT NULL AUTO_INCREMENT,
        `contact_id` INT(11) NOT NULL DEFAULT '-1',
        `company_name` VARCHAR(128) NOT NULL DEFAULT '',
        `company_department` VARCHAR(128) NOT NULL DEFAULT '',
        `company_additional` VARCHAR(128) NOT NULL DEFAULT '',
        `company_additional_2` VARCHAR(128) NOT NULL DEFAULT '',
        `company_additional_3` VARCHAR(128) NOT NULL DEFAULT '',
        `company_primary_address_id` INT(11) NOT NULL DEFAULT '-1',
        `company_primary_person_id` INT(11) NOT NULL DEFAULT '-1',
        `company_primary_phone_id` INT(11) NOT NULL DEFAULT '-1',
        `company_primary_email_id` INT(11) NOT NULL DEFAULT '-1',
        `company_primary_note_id` INT(11) NOT NULL DEFAULT '-1',
        `company_status` ENUM('ACTIVE', 'LOCKED', 'DELETED') NOT NULL DEFAULT 'ACTIVE',
        `company_timestamp` TIMESTAMP,
        PRIMARY KEY (`company_id`),
        UNIQUE (`contact_id`)
        )
    COMMENT='The main contact table'
    ENGINE=InnoDB
    AUTO_INCREMENT=1
    DEFAULT CHARSET=utf8
    COLLATE='utf8_general_ci'
EOD;
        try {
            $this->app['db']->query($SQL);
            $this->app['monolog']->addInfo("Created table 'contact_company'", array(__METHOD__, __LINE__));
        } catch (\Doctrine\DBAL\DBALException $e) {
            throw new \Exception($e);
        }
    }

    /**
     * Return a default (empty) PERSON contact record.
     *
     * @return array
     */
    public function getDefaultRecord()
    {
        return array(
            'company_id' => -1,
            'contact_id' => -1,
            'company_name' => '',
            'company_department' => '',
            'company_additional' => '',
            'company_additional_2' => '',
{'fraction_non_alphanumeric': 0.13168411037107516, 'fraction_numerical': 0.018268315889628926, 'mean_word_length': 2.5180722891566263, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 35, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6476862', 'n_tokens_mistral': 1696, 'n_tokens_neox': 1606, 'n_words': 379}