FileObject   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 67
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 67
loc 67
ccs 15
cts 15
cp 1
rs 10
wmc 9
lcom 1
cbo 1

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getLinkTarget() 4 4 1
A flock() 4 4 2
A hasChildren() 4 4 1
A getChildren() 4 4 1
A isDot() 4 4 1
A dummyScale() 8 8 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/*******************************************************************
3
 * Created by:  Marko Kungla @ OkramLabs on Aug 6, 2012 - 10:02:48
4
 * Contact:     [email protected] - https://okramlabs.com
5
 * @copyright   2015 OkramLabs - https://okramlabs.com
6
 * @license     MIT
7
 *
8
 * Package name:libhowi-filesystem
9
 * @category	HOWI3
10
 * @package		libhowi
11
 * @subpackage	filesystem
12
 * 
13
 * Lang:      PHP
14
 * Encoding:  UTF-8
15
 * File:      fileObject.inc
16
 * @link      https://
17
 ********************************************************************
18
 * Contributors:
19
 * @author Marko Kungla <[email protected]>
20
 *           Github: https://github.com/mkungla
21
 ********************************************************************
22
 * Comments:
23
 */
24
namespace HOWI3\libhowi\Filesystem\php5\Objects;
25
26
use \SplFileObject;
27
use \HOWI3\libhowi\Filesystem\Commons\ObjectInterfaces\FileInterface;
28
use \HOWI3\libhowi\Filesystem\php5\TraitForSharedMethods;
29
30 View Code Duplication
class FileObject extends SplFileObject implements FileInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
Bug introduced by
There is one abstract method fread in this class; you could implement it, or declare this class as abstract.
Loading history...
31
{
32
    use TraitForSharedMethods;
33
34
    /**
35
     *
36
     * {@inheritDoc}
37
     *
38
     */
39 2
    public function getLinkTarget()
40
    {
41 2
        return false;
42
    }
43
44
    /**
45
     *
46
     * {@inheritDoc}
47
     *
48
     */
49 2
    public function flock($operation, &$wouldblock = NULL)
50
    {
51 2
        return ! $wouldblock ? parent::flock($operation) : parent::flock($operation, $wouldblock);
52
    }
53
54
    /**
55
     *
56
     * {@inheritDoc}
57
     *
58
     */
59 2
    public function hasChildren()
60
    {
61 2
        return false;
62
    }
63
64
    /**
65
     *
66
     * {@inheritDoc}
67
     *
68
     */
69 2
    public function getChildren()
70
    {
71 2
        return false;
72
    }
73
74
    /**
75
     *
76
     * {@inheritDoc}
77
     *
78
     */
79 4
    public function isDot()
80
    {
81 4
        return false;
82
    }
83
    
84
    /**
85
     * Dummy file scale up to x bytes
86
     * @param int $size
87
     */
88 2
    public function dummyScale($size)
89
    {
90 2
        if(!is_int($size) || $this->getSize() > $size) return false;
91
        
92 2
        $this->fseek($size ,SEEK_SET);
93 2
        $this->fwrite(' ');
94 2
        return true;
95
    }
96
}
97