Completed
Pull Request — master (#227)
by Patrick
15:26 queued 13:59
created

Content::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 3
nc 1
nop 2
crap 2
1
<?php
2
/**
3
 * ownCloud - files_antivirus
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Viktar Dubiniuk <[email protected]>
9
 *
10
 * @copyright Viktar Dubiniuk 2015-2018
11
 * @license AGPL-3.0
12
 */
13
14
namespace OCA\Files_Antivirus;
15
16
class Content implements IScannable {
17
	
18
	protected $content;
19
	
20
	protected $currentPosition = 0;
21
	
22
	protected $chunkSize;
23
	
24
	public function __construct($content, $chunkSize) {
25
		$this->content = $content;
26
		$this->chunkSize = $chunkSize;
27
	}
28
	
29
	public function fread() {
30
		if ($this->currentPosition >= \strlen($this->content)) {
31
			return false;
32
		}
33
		$chunk = \substr($this->content, $this->currentPosition, $this->chunkSize);
34
		$this->currentPosition = $this->currentPosition + $this->chunkSize;
35
		
36
		return $chunk;
37
	}
38
}
39