<commit_before><?php

class PersonService
{

    function photo($id)
    {
        $sSQL = 'SELECT per_ID, per_FirstName, per_LastName, per_Gender, per_Email FROM person_per WHERE per_ID =' . $id;
        $person = RunQuery($sSQL);
        extract(mysql_fetch_array($person));

        if ($per_ID != "") {

            $photoFile = $this->getUploadedPhoto($per_ID);

            if ($photoFile == "" && $per_Email != "") {
                $photoFile = $this->getGravatar($per_Email);
            }

            if ($photoFile == "") {
                $photoFile = $this->getDefaultPhoto();
            }

            echo $photoFile;
        } else {
            echo "{ error: person not found for id ".$id. "}";
        }

    }

    private
    function getUploadedPhoto($personId)
    {
        $validextensions = array("jpeg", "jpg", "png");
        $hasFile = false;
        while (list(, $ext) = each($validextensions)) {
            $photoFile = "../Images/Person/thumbnails/" . $personId . "." . $ext;
            if (file_exists($photoFile)) {
                $hasFile = true;
                $photoFile = "Images/Person/thumbnails/" . $personId . "." . $ext;
                break;
            }
        }

        if ($hasFile) {
            return $photoFile;
        } else {
            return "";
        }
    }

    private
    function getGravatar($email, $s = 60, $d = '404', $r = 'g', $img = false, $atts = array())
    {
        $url = 'http://www.gravatar.com/avatar/';
        $url .= md5(strtolower(trim($email)));
        $url .= "?s=$s&d=$d&r=$r";

        $headers = @get_headers($url);
        if (strpos($headers[0], '404') === false) {
            return $url;
        } else {
            return "";
        }
    }

    function search($searchTerm)
    {
        $fetch = 'SELECT per_ID, per_FirstName, per_LastName, CONCAT_WS(" ",per_FirstName,per_LastName) AS fullname, per_fam_ID  FROM person_per WHERE per_FirstName LIKE \'%' . $searchTerm . '%\' OR per_LastName LIKE \'%' . $searchTerm . '%\' OR per_Email LIKE \'%' . $searchTerm . '%\' OR CONCAT_WS(" ",per_FirstName,per_LastName) LIKE \'%' . $searchTerm . '%\' LIMIT 15';
        $result = mysql_query($fetch);

        $return = array();
        while ($row = mysql_fetch_array($result)) {
            $values['id'] = $row['per_ID'];
            $values['famID'] = $row['per_fam_ID'];
            $values['per_FirstName'] = $row['per_FirstName'];
            $values['per_LastName'] = $row['per_LastName'];
            $values['value'] = $row['per_FirstName'] . " " . $row['per_LastName'];

            array_push($return, $values);
        }
<commit_msg>Cleaner APIs<commit_after><?php

class PersonService
{

    function photo($id)
    {
        $sSQL = 'SELECT per_ID, per_FirstName, per_LastName, per_Gender, per_Email FROM person_per WHERE per_ID =' . $id;
        $person = RunQuery($sSQL);
        extract(mysql_fetch_array($person));

        if ($per_ID != "") {

            $photoFile = $this->getUploadedPhoto($per_ID);

            if ($photoFile == "" && $per_Email != "") {
                $photoFile = $this->getGravatar($per_Email);
            }

            if ($photoFile == "") {
                $photoFile = $this->getDefaultPhoto();
            }

            echo $photoFile;
        } else {
            echo "{ error: person not found for id ".$id. "}";
        }

    }

    private
    function getUploadedPhoto($personId)
    {
        $validextensions = array("jpeg", "jpg", "png");
        $hasFile = false;
        while (list(, $ext) = each($validextensions)) {
            $photoFile = "../Images/Person/thumbnails/" . $personId . "." . $ext;
            if (file_exists($photoFile)) {
                $hasFile = true;
                $photoFile = "Images/Person/thumbnails/" . $personId . "." . $ext;
                break;
            }
        }

        if ($hasFile) {
            return $photoFile;
        } else {
            return "";
        }
    }

    private
    function getGravatar($email, $s = 60, $d = '404', $r = 'g', $img = false, $atts = array())
    {
        $url = 'http://www.gravatar.com/avatar/';
        $url .= md5(strtolower(trim($email)));
        $url .= "?s=$s&d=$d&r=$r";

        $headers = @get_headers($url);
        if (strpos($headers[0], '404') === false) {
            return $url;
        } else {
            return "";
        }
    }

    function search($searchTerm)
    {
        $fetch = 'SELECT per_ID, per_FirstName, per_LastName, CONCAT_WS(" ",per_FirstName,per_LastName) AS fullname, per_fam_ID  FROM person_per WHERE per_FirstName LIKE \'%' . $searchTerm . '%\' OR per_LastName LIKE \'%' . $searchTerm . '%\' OR per_Email LIKE \'%' . $searchTerm . '%\' OR CONCAT_WS(" ",per_FirstName,per_LastName) LIKE \'%' . $searchTerm . '%\' order by per_FirstName LIMIT 15';
        $result = mysql_query($fetch);

        $return = array();
        while ($row = mysql_fetch_array($result)) {
            $values['id'] = $row['per_ID'];
            $values['familyID'] = $row['per_fam_ID'];
            $values['firstName'] = $row['per_FirstName'];
            $values['lastName'] = $row['per_LastName'];
            $values['fullName'] = $row['per_FirstName'] . " " . $row['per_LastName'];

            array_push($return, $values);
        }

{'fraction_non_alphanumeric': 0.17237485886337975, 'fraction_numerical': 0.004516371847948814, 'mean_word_length': 1.9511382565241533, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6426746', 'n_tokens_mistral': 1742, 'n_tokens_neox': 1660, 'n_words': 320}