Piwik\Segment::getHash PHP Method

getHash() public method

Returns a hash of the segment condition, or the empty string if the segment condition is empty.
public getHash ( ) : string
return string
    public function getHash()
    {
        if (empty($this->string)) {
            return '';
        }
        // normalize the string as browsers may send slightly different payloads for the same archive
        $normalizedSegmentString = urldecode($this->string);
        return md5($normalizedSegmentString);
    }

Usage Example

 private function insertNumericArchive($tableMonth, $idSite, $period, $date1, $date2, $segment, $doneValue)
 {
     $this->insertRow('archive_numeric', $tableMonth, $idSite, $period, $date1, $date2, 'nb_schweetz', 2);
     $this->insertRow('archive_numeric', $tableMonth, $idSite, $period, $date1, $date2, 'nb_fixes', 3);
     $this->insertRow('archive_numeric', $tableMonth, $idSite, $period, $date1, $date2, 'nb_wrecks', 4);
     $doneFlag = 'done';
     if (!empty($segment)) {
         $segmentObj = new Segment($segment, array());
         $doneFlag .= $segmentObj->getHash();
     }
     $this->insertRow('archive_numeric', $tableMonth, $idSite, $period, $date1, $date2, $doneFlag, $doneValue);
 }
All Usage Examples Of Piwik\Segment::getHash