Completed
Push — antivirus-update ( fcda38...b6d85d )
by Victor
08:14
created

Content   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 3
c 2
b 1
f 1
lcom 1
cbo 0
dl 0
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A fread() 0 9 2
1
<?php
2
/**
3
 * Copyright (c) 2015 Victor 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 $storage;
16
	
17
	protected $currentPosition = 0;
18
	
19
	protected $chunkSize;
20
	
21
	public function __construct($content, $storage, $chunkSize){
22
		$this->content = $content;
23
		$this->storage = $storage;
24
		$this->chunkSize = $chunkSize;
25
	}
26
	
27
	public function fread(){
28
		if ($this->currentPosition >=  strlen($this->content)) {
29
			return false;
30
		}
31
		$chunk = substr($this->content, $this->currentPosition, $this->chunkSize);
32
		$this->currentPosition = $this->currentPosition + $this->chunkSize;
33
		
34
		return $chunk;
35
	}
36
}
37