<commit_before><?php

namespace fennecweb\ajax\details;

use \PDO as PDO;

/**
 * Web Service.
 * Returns Trait information of an organism by its id
 */
class TraitsOfOrganism extends \fennecweb\WebService
{

    private $db;

    /**
     * @param $querydata[]
     * @returns organism id
     */
    public function execute($querydata)
    {
        $this->db = $this->openDbConnection($querydata);
        $organism_id = $querydata['organism_id'];
        $query_get_traits_to_organism = <<<EOF
SELECT *
    FROM trait_entry WHERE organism_id = :organism_id
EOF;
        $stm_get_traits_to_organism = $this->db->prepare($query_get_traits_to_organism);
        $stm_get_traits_to_organism->bindValue('organism_id', $organism_id);
        $stm_get_traits_to_organism->execute();

        $result = array();
        while ($row = $stm_get_traits_to_organism->fetch(PDO::FETCH_ASSOC)) {
            $this_trait = [];
            $this_trait['type'] = $this->get_cvterm($row['type_cvterm_id']);
            if ($row['value'] != null) {
                $this_trait['value'] = $row['value'];
            } else {
                $this_trait['value'] = $this->get_cvterm($row['value_cvterm_id']);
            }
            array_push($result, $this_trait);
        }
        return $result;
    }
    
    /**
     * Function which returns the cvterm accoring to a trait_entry_id
     * @param $trait_entry_id
     * @return cvterm to a given trait_entry_id
     */
    private function get_cvterm($trait_entry_id)
    {
        $query_get_cvterm = <<<EOF
SELECT name, definition FROM trait_cvterm WHERE trait_cvterm_id = :trait_entry_id
EOF;
        $stm_get_cvterm = $this->db->prepare($query_get_cvterm);
        $stm_get_cvterm->bindValue('trait_entry_id', $trait_entry_id);
        $stm_get_cvterm->execute();
        $result = $stm_get_cvterm->fetch(PDO::FETCH_ASSOC);
        
        return ($result['name'] == null) ? $result['definition'] : $result['name'];
    }
}
<commit_msg>Rename function to use camel case<commit_after><?php

namespace fennecweb\ajax\details;

use \PDO as PDO;

/**
 * Web Service.
 * Returns Trait information of an organism by its id
 */
class TraitsOfOrganism extends \fennecweb\WebService
{

    private $db;

    /**
     * @param $querydata[]
     * @returns organism id
     */
    public function execute($querydata)
    {
        $this->db = $this->openDbConnection($querydata);
        $organism_id = $querydata['organism_id'];
        $query_get_traits_to_organism = <<<EOF
SELECT *
    FROM trait_entry WHERE organism_id = :organism_id
EOF;
        $stm_get_traits_to_organism = $this->db->prepare($query_get_traits_to_organism);
        $stm_get_traits_to_organism->bindValue('organism_id', $organism_id);
        $stm_get_traits_to_organism->execute();

        $result = array();
        while ($row = $stm_get_traits_to_organism->fetch(PDO::FETCH_ASSOC)) {
            $this_trait = [];
            $this_trait['type'] = $this->getCvterm($row['type_cvterm_id']);
            if ($row['value'] != null) {
                $this_trait['value'] = $row['value'];
            } else {
                $this_trait['value'] = $this->getCvterm($row['value_cvterm_id']);
            }
            array_push($result, $this_trait);
        }
        return $result;
    }
    
    /**
     * Function which returns the cvterm accoring to a trait_entry_id
     * @param $trait_entry_id
     * @return cvterm to a given trait_entry_id
     */
    private function getCvterm($trait_entry_id)
    {
        $query_get_cvterm = <<<EOF
SELECT name, definition FROM trait_cvterm WHERE trait_cvterm_id = :trait_entry_id
EOF;
        $stm_get_cvterm = $this->db->prepare($query_get_cvterm);
        $stm_get_cvterm->bindValue('trait_entry_id', $trait_entry_id);
        $stm_get_cvterm->execute();
        $result = $stm_get_cvterm->fetch(PDO::FETCH_ASSOC);
        
        return ($result['name'] == null) ? $result['definition'] : $result['name'];
    }
}

{'fraction_non_alphanumeric': 0.13557619884509164, 'fraction_numerical': 0.0, 'mean_word_length': 2.8455598455598454, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 31, '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': '5318445', 'n_tokens_mistral': 1346, 'n_tokens_neox': 1336, 'n_words': 231}