Content::fread()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 0
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
	protected $content;
18
	
19
	protected $currentPosition = 0;
20
	
21
	protected $chunkSize;
22
	
23 3
	public function __construct($content, $chunkSize) {
24 3
		$this->content = $content;
25 3
		$this->chunkSize = $chunkSize;
26 3
	}
27
	
28 3
	public function fread() {
29 3
		if ($this->currentPosition >= \strlen($this->content)) {
30 3
			return false;
31
		}
32 3
		$chunk = \substr($this->content, $this->currentPosition, $this->chunkSize);
33 3
		$this->currentPosition = $this->currentPosition + $this->chunkSize;
34
		
35 3
		return $chunk;
36
	}
37
}
38