Completed
Push — master ( d5f8b0...0fe70c )
by mehdi
02:20
created

DayOf   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 56
Duplicated Lines 25 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 8
Bugs 1 Features 6
Metric Value
wmc 3
c 8
b 1
f 6
lcom 1
cbo 0
dl 14
loc 56
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A year() 7 7 1
A week() 7 7 1

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 namespace Datium\Tools;
2
3
/**
4
 * Define Day of current date.
5
 */
6
class DayOf {
7
8
  protected $date_time;
9
10
  protected $month;
11
12
  protected $day;
13
14
  protected $config;
15
16
  protected $result;
17
18
  protected $calendar_type;
19
20
  protected $geregorian_DayofWeek;
21
22
  public function __construct( $date_time, $calendar_type = 'gregorian' ) {
23
24
    $this->config = include( 'Config.php' );
25
26
    $this->date_time = $date_time;
27
28
    $this->calendar_type = $calendar_type;
29
30
    return $this;
0 ignored issues
show
Bug introduced by
Constructors do not have meaningful return values, anything that is returned from here is discarded. Are you sure this is correct?
Loading history...
31
32
  }
33
34
  /**
35
   * Which day of year is current day.
36
   * @since Aug, 03 2015
37
   * @return integer
38
   */
39 View Code Duplication
  public function year() {
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...
40
41
    $this->config = include(  'CalendarSettings/' . ucfirst( $this->calendar_type ) . '.php' );
42
43
    return $this->config[ 'day_of_year' ]( $this->date_time );
44
45
  }
46
47
48
  /**
49
   * Which day of week is current day.
50
   * @since Aug, 09 2015
51
   * @return integer
52
   */
53 View Code Duplication
  public function week() {
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...
54
55
    $this->config = include(  'CalendarSettings/' . ucfirst( $this->calendar_type ) . '.php' );
56
57
    return $this->config[ 'day_of_week' ]( $this->date_time );
58
59
  }
60
61
}
62