BrowscapPHP\Helper\Converter::getIniVersion PHP Method

getIniVersion() public method

Parses the ini data to get the version of loaded ini file
public getIniVersion ( string $iniString ) : integer
$iniString string The loaded ini data
return integer
    public function getIniVersion($iniString)
    {
        $quoterHelper = new Quoter();
        $key = $quoterHelper->pregQuote(self::BROWSCAP_VERSION_KEY);
        if (preg_match('/\\.*\\[' . $key . '\\][^\\[]*Version=(\\d+)\\D.*/', $iniString, $matches)) {
            if (isset($matches[1])) {
                $this->iniVersion = (int) $matches[1];
            }
        }
        return $this->iniVersion;
    }

Usage Example

Example #1
0
    /**
     *
     */
    public function testGetIniVersion()
    {
        $file = $this->getMock('\\BrowscapPHP\\Helper\\Filesystem', array('exists'), array(), '', false);
        $file->expects(self::never())->method('exists')->will(self::returnValue(false));
        $this->object->setFilesystem($file);
        $content = ';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Browscap Version

[GJK_Browscap_Version]
Version=5031
Released=Mon, 30 Jun 2014 17:55:58 +0200
Format=ASP
Type=';
        self::assertSame(5031, $this->object->getIniVersion($content));
        self::assertSame($this->object, $this->object->storeVersion());
    }
All Usage Examples Of BrowscapPHP\Helper\Converter::getIniVersion