Passed
Push — master ( 56a869...1425a4 )
by Filippo
02:07 queued 15s
created

ChecksIntegrity::isLastChunk()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 2 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 3
dl 0
loc 5
rs 10
c 2
b 2
f 0
1
<?php
2
3
namespace Jobtech\LaravelChunky\Strategies\Concerns;
4
5
trait ChecksIntegrity
6
{
7
    /**
8
     * {@inheritdoc}
9
     */
10
    public function checkIntegrity(int $chunk_size, int $total_size): bool
11
    {
12
        $total = 0;
13
        $chunks = $this->chunks(
0 ignored issues
show
Bug introduced by
It seems like chunks() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

13
        /** @scrutinizer ignore-call */ 
14
        $chunks = $this->chunks(
Loading history...
14
            $this->chunksFolder()
0 ignored issues
show
Bug introduced by
It seems like chunksFolder() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

14
            $this->/** @scrutinizer ignore-call */ 
15
                   chunksFolder()
Loading history...
15
        );
16
17
        foreach ($chunks as $chunk) {
18
            $size = $this->chunksFilesystem()->size($chunk->getPath());
0 ignored issues
show
Bug introduced by
It seems like chunksFilesystem() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
            $size = $this->/** @scrutinizer ignore-call */ chunksFilesystem()->size($chunk->getPath());
Loading history...
19
20
            if ($size < $chunk_size && ! $chunk->isLast()) {
21
                return false;
22
            }
23
24
            $total += $size;
25
        }
26
27
        return $total >= $total_size;
28
    }
29
}
30