Swiftriver\UshahidiAPIInterface\ContentToUshahidiAPIParser::ExtractLocationNameFromContent PHP Method

ExtractLocationNameFromContent() private method

Given a content item, this function extracts the first where tag from its tags collection or returns 'unknown'
private ExtractLocationNameFromContent ( Content $content ) : string
$content Swiftriver\Core\ObjectModel\Content
return string
    private function ExtractLocationNameFromContent($content)
    {
        //if there are no tags then just return the defult
        if (!isset($content->tags) || !is_array($content->tags)) {
            return "unknown";
        }
        //Set up the return variable with the defaul value
        $return = "";
        //loop through the content tags
        foreach ($content->tags as $tag) {
            //we are only interested in the where tag
            if ($tag->type == "where") {
                //set the location
                $return .= $tag->text . ", ";
            }
        }
        //If no where tags, return unknown
        if (strlen($return) == 0) {
            return "unknown";
        }
        //trim the extra comma and space off the end
        $return = rtrim($return, " ,");
        //return the location
        return $return;
    }