Inital commit for unit test configuration
This commit is contained in:

committed by
Manish Verma

parent
2f0796e954
commit
e0436b7757
@@ -1,33 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use const PHP_EOL;
|
||||
use function fclose;
|
||||
use function fgets;
|
||||
use function fopen;
|
||||
use function is_file;
|
||||
use function serialize;
|
||||
use function time;
|
||||
use function unserialize;
|
||||
|
||||
/**
|
||||
* Filesystem cache driver.
|
||||
*
|
||||
* @since 2.3
|
||||
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
||||
*/
|
||||
class FilesystemCache extends FileCache
|
||||
{
|
||||
const EXTENSION = '.doctrinecache.data';
|
||||
public const EXTENSION = '.doctrinecache.data';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
@@ -46,13 +35,14 @@ class FilesystemCache extends FileCache
|
||||
$lifetime = -1;
|
||||
$filename = $this->getFilename($id);
|
||||
|
||||
if ( ! is_file($filename)) {
|
||||
if (! is_file($filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$resource = fopen($filename, "r");
|
||||
$resource = fopen($filename, 'r');
|
||||
$line = fgets($resource);
|
||||
|
||||
if (false !== ($line = fgets($resource))) {
|
||||
if ($line !== false) {
|
||||
$lifetime = (int) $line;
|
||||
}
|
||||
|
||||
@@ -62,7 +52,7 @@ class FilesystemCache extends FileCache
|
||||
return false;
|
||||
}
|
||||
|
||||
while (false !== ($line = fgets($resource))) {
|
||||
while (($line = fgets($resource)) !== false) {
|
||||
$data .= $line;
|
||||
}
|
||||
|
||||
@@ -79,13 +69,14 @@ class FilesystemCache extends FileCache
|
||||
$lifetime = -1;
|
||||
$filename = $this->getFilename($id);
|
||||
|
||||
if ( ! is_file($filename)) {
|
||||
if (! is_file($filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$resource = fopen($filename, "r");
|
||||
$resource = fopen($filename, 'r');
|
||||
$line = fgets($resource);
|
||||
|
||||
if (false !== ($line = fgets($resource))) {
|
||||
if ($line !== false) {
|
||||
$lifetime = (int) $line;
|
||||
}
|
||||
|
||||
@@ -103,8 +94,8 @@ class FilesystemCache extends FileCache
|
||||
$lifeTime = time() + $lifeTime;
|
||||
}
|
||||
|
||||
$data = serialize($data);
|
||||
$filename = $this->getFilename($id);
|
||||
$data = serialize($data);
|
||||
$filename = $this->getFilename($id);
|
||||
|
||||
return $this->writeFile($filename, $lifeTime . PHP_EOL . $data);
|
||||
}
|
||||
|
Reference in New Issue
Block a user