forked from magento/magento2-functional-testing-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFile.php
65 lines (59 loc) · 1.14 KB
/
File.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\FunctionalTestingFramework\Util\Iterator;
/**
* Class File
*
* @api
*/
class File extends AbstractIterator
{
/**
* Cached files content
*
* @var array
*/
protected $cached = [];
/**
* File constructor.
* @param array $paths
*/
public function __construct(array $paths)
{
$this->data = $paths;
$this->initFirstElement();
}
/**
* Return filename of current file object
*
* @return string
*/
public function getFilename()
{
return $this->data[$this->key()];
}
/**
* Get file content
*
* @return string
*/
public function current()
{
if (!isset($this->cached[$this->current])) {
$this->cached[$this->current] = file_get_contents($this->current);
}
return $this->cached[$this->current];
}
/**
* Check if current element is valid
*
* @return boolean
*/
protected function isValid()
{
return true;
}
}