GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

GridFSFile   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 87
c 0
b 0
f 0
wmc 13
lcom 1
cbo 3
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A getMongoGridFsFile() 0 4 1
A getFilename() 0 4 1
A count() 0 4 1
A getMd5Checksum() 0 4 1
A save() 0 4 1
A dump() 0 4 1
A getBytes() 0 4 1
A getResource() 0 4 1
A delete() 0 4 1
A __construct() 0 17 4
1
<?php
2
3
/**
4
 * This file is part of the PHPMongo package.
5
 *
6
 * (c) Dmytro Sokil <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sokil\Mongo;
13
14
class GridFSFile extends Structure implements \Countable
15
{
16
    /**
17
     *
18
     * @var \Sokil\Mongo\GridFS
19
     */
20
    private $gridFS;
21
    
22
    /**
23
     * @var \MongoGridFSFile
24
     */
25
    private $file;
26
        
27
    /**
28
     *
29
     * @param \Sokil\Mongo\GridFS $gridFS instance of GridFS
30
     * @param array|\MongoGridFSFile $file instance of File or metadata array
31
     * @throws \Sokil\Mongo\Exception
32
     */
33
    public function __construct(GridFS $gridFS, $file = null)
34
    {
35
        $this->gridFS = $gridFS;
36
        
37
        if (!$file) {
38
            return;
39
        }
40
41
        if (is_array($file)) {
42
            $file = new \MongoGridFSFile($gridFS->getMongoCollection(), $file);
43
        } elseif (!($file instanceof \MongoGridFSFile)) {
44
            throw new Exception('Wrong file data specified');
45
        }
46
47
        $this->file = $file;
48
        $this->setDataReference($file->file);
49
    }
50
    
51
    /**
52
     * Get instance of native mongo file
53
     *
54
     * @return \MongoGridFSFile
55
     */
56
    public function getMongoGridFsFile()
57
    {
58
        return $this->file;
59
    }
60
    
61
    public function getFilename()
62
    {
63
        return $this->file->getFilename();
64
    }
65
    
66
    public function count()
67
    {
68
        return $this->file->getSize();
69
    }
70
    
71
    public function getMd5Checksum()
72
    {
73
        return $this->file->file['md5'];
74
    }
75
    
76
    public function save()
77
    {
78
        $this->gridFS->getMongoCollection()->save($this->file->file);
79
    }
80
    
81
    public function dump($filename)
82
    {
83
        $this->file->write($filename);
84
    }
85
    
86
    public function getBytes()
87
    {
88
        return $this->file->getBytes();
89
    }
90
    
91
    public function getResource()
92
    {
93
        return $this->file->getResource();
94
    }
95
    
96
    public function delete()
97
    {
98
        $this->gridFS->deleteFileById($this->get('_id'));
99
    }
100
}
101