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.

FileManagerDatabaseStorage::removeFile()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
3
namespace rdx\filemanager;
4
5
use Carbon\Carbon;
6
use Illuminate\Database\ConnectionInterface;
7
use rdx\filemanager\ManagedFile;
8
9
class FileManagerDatabaseStorage implements FileManagerStorage {
10
11
	protected $connection;
12
	protected $options = [];
13
14
	/**
15
	 *
16
	 */
17
	public function __construct(ConnectionInterface $connection, array $options = []) {
18
		$this->connection = $connection;
19
		$this->options = $options;
20
	}
21
22
	/**
23
	 *
24
	 */
25
	public function getUsageCount(ManagedFile $file) {
26
		return $this->connection
27
			->table($this->options['usage_table'])
28
			->where('file_id', $file->id)
29
			->count();
30
	}
31
32
	/**
33
	 *
34
	 */
35
	public function getUsages(ManagedFile $file) {
36
		return $this->connection
37
			->table($this->options['usage_table'])
38
			->where('file_id', $file->id)
39
			->get();
40
	}
41
42
	/**
43
	 *
44
	 */
45
	public function getFiles(array $conditions = [], array $options = []) {
46
		$query = $this->connection->table($this->options['files_table']);
47
48
		foreach ($conditions as $column => $value) {
49
			$query->where($column, $value);
50
		}
51
52
		return $query->get();
53
	}
54
55
	/**
56
	 *
57
	 */
58
	public function getFileByPath($path) {
59
		return $this->connection
60
			->table($this->options['files_table'])
61
			->where('filepath', $path)
62
			->first();
63
	}
64
65
	/**
66
	 *
67
	 */
68
	public function getFile($id) {
69
		return $this->connection
70
			->table($this->options['files_table'])
71
			->where('id', $id)
72
			->first();
73
	}
74
75
	/**
76
	 *
77
	 */
78 View Code Duplication
	public function addFile(ManagedFile $file) {
0 ignored issues
show
Duplication introduced by
This method 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...
79
		$file->id = $this->connection->table($this->options['files_table'])->insertGetId([
80
			'filepath' => $file->filepath,
81
			'filename' => $file->filename,
82
			'created_at' => new Carbon,
83
			'created_by' => \Auth::id(),
84
		]);
85
	}
86
87
	/**
88
	 *
89
	 */
90
	public function removeFile(ManagedFile $file) {
91
92
	}
93
94
	/**
95
	 *
96
	 */
97 View Code Duplication
	public function addUsage(ManagedFile $file, array $params) {
0 ignored issues
show
Duplication introduced by
This method 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...
98
		$params = [
99
			'file_id' => $file->id,
100
			'created_at' => new Carbon,
101
			'created_by' => \Auth::id(),
102
		] + $params;
103
104
		return $this->connection->table($this->options['usage_table'])->insert($params);
105
	}
106
107
	/**
108
	 *
109
	 */
110
	public function removeUsage(ManagedFile $file = null, array $params) {
111
		$query = $this->connection->table($this->options['usage_table']);
112
113
		if ($file) {
114
			$query->where('file_id', $file->id);
115
		}
116
117
		foreach ($params as $column => $value) {
118
			$query->where($column, $value);
119
		}
120
121
		return $query->delete();
122
	}
123
124
}
125