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

Content   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 23
ccs 0
cts 12
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A fread() 0 9 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