Completed
Push — master ( 86ba99...4fe26b )
by
unknown
03:43
created

Content::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

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