DNDataTransfer   B
last analyzed

Complexity

Total Complexity 27

Size/Duplication

Total Lines 274
Duplicated Lines 14.6 %

Coupling/Cohesion

Components 1
Dependencies 16

Importance

Changes 0
Metric Value
wmc 27
lcom 1
cbo 16
dl 40
loc 274
rs 8.4614
c 0
b 0
f 0

16 Methods

Rating   Name   Duplication   Size   Complexity  
A map_resque_status() 10 10 1
A setBackupBeforePush() 0 3 1
A getTitle() 0 3 1
A Link() 0 3 1
A LogLink() 0 3 1
A getDefaultSearchContext() 0 7 1
B getCMSFields() 0 24 1
B start() 13 36 3
A canView() 0 3 1
A logfile() 0 7 1
A log() 0 3 1
A LogContent() 0 3 1
A getDescription() 0 16 4
A getModeNice() 0 7 2
A IsBackupDataTransfer() 0 19 3
A ResqueStatus() 17 17 4

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
/**
4
 * Class representing a single data transfer in a project,
5
 * which can include a database export, an archive of all assets, or both.
6
 *
7
 * It can be one of two directions:
8
 * - Backup: Package up data on an environment and store it in a local file
9
 * - Restore: Transfer data from a local file into an environment, extract assets and/or restore a database
10
 *
11
 * The choice of database and/or assets is represented in the "Mode".
12
 * There's always one file archive involved (stored as the has_one "ArchiveFile") on the local Deploynaut environment.
13
 *
14
 * Each transfer is executed by a Resque job, so the model also contains
15
 * a reference to a Resque token (which might still be in progress).
16
 *
17
 * The "Environment" points to the source or target involved.
18
 *
19
 * @property string $ResqueToken
20
 * @property string $Status
21
 * @property string $Direction
22
 * @property string $Mode
23
 * @property string $Origin
24
 *
25
 * @method DNEnvironment Environment()
26
 * @property int EnvironmentID
27
 * @method Member Author()
28
 * @property int AuthorID
29
 * @method DNDataArchive DataArchive()
30
 * @property int DataArchiveID
31
 * @method DNDataTransfer BackupDataTransfer()
32
 * @property int BackupDataTransferID
33
 */
34
class DNDataTransfer extends DataObject {
0 ignored issues
show
Coding Style introduced by
The property $has_one is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
Coding Style introduced by
The property $singular_name is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
Coding Style introduced by
The property $plural_name is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
Coding Style introduced by
The property $summary_fields is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
Coding Style introduced by
The property $searchable_fields is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
35
36
	private static $db = array(
37
		"ResqueToken" => "Varchar(255)",
38
		// Observe that this is not the same as Resque status, since ResqueStatus is not persistent.
39
		"Status" => "Enum('Queued, Started, Finished, Failed, n/a', 'n/a')",
40
		"Direction" => "Enum('get, push', 'get')",
41
		"Mode" => "Enum('all, assets, db', '')",
42
		"Origin" => "Enum('EnvironmentTransfer,ManualUpload', 'EnvironmentTransfer')",
43
		"IncludeResampled" => "Boolean",
44
	);
45
46
	private static $has_one = array(
0 ignored issues
show
Comprehensibility introduced