Completed
Push — master ( 9d3985...36dc74 )
by Reginaldo
58:24 queued 24:12
created

QueueProduct::planilhaProcessedIncomplete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
class QueueProduct extends AppModel {
4
	
5
	public function loadPlanilhasNotProcesseds() {
6
		$planilhas = $this->find('all', array(
7
				array('conditions' => array(
8
						array('OR' => array(
9
								'QueueProduct.processado' => 0,
10
								'QueueProduct.processado' => 2
11
							)
12
						)
13
					)
14
				)
15
			)
16
		);
17
18
		$response = [];
19
		foreach ($planilhas as $planilha) {
0 ignored issues
show
Bug introduced by
The expression $planilhas of type null|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
20
			$response[] = [
21
				'caminho' => $planilha['QueueProduct']['caminho'],
22
				'usuario_id' => $planilha['QueueProduct']['usuario_id'],
23
				'id' => $planilha['QueueProduct']['id']
24
			];
25
		}
26
27
		return $response;
28
	}
29
30
	public function planilhaProcessedIncomplete($planilhaId) {
31
		$dados = array ('QueueProduct.processado' => '2');
32
		$parametros = array ('QueueProduct.id' => $planilhaId);
33
34
		return $this->updateAll($dados, $parametros);
35
	}
36
37
	public function planilhaProcessedComplete($planilhaId) {
38
		$dados = array ('QueueProduct.processado' => '1');
39
		$parametros = array ('QueueProduct.id' => $planilhaId);
40
41
		return $this->updateAll($dados, $parametros);
42
	}
43
44
}