Completed
Push — master ( eef885...465d0c )
by
unknown
30:08 queued 12:49
created

Date_Util   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A construct() 0 1 1
A formatte_date() 0 9 2
A mysqldate2wordpress() 0 8 2
1
<?php
2
/**
3
 * Gestion des dates
4
 *
5
 * @package Evarisk\Plugin
6
 */
7
8
namespace eoxia;
9
10
if ( ! defined( 'ABSPATH' ) ) {
11
	exit;
12
}
13
14
if ( ! class_exists( '\eoxia\Date_Util' ) ) {
15
	/**
16
	 * Gestion des dates
17
	 *
18
	 * @author Jimmy Latour <[email protected]>
19
	 * @version 1.1.0.0
20
	 */
21
	class Date_Util extends \eoxia\Singleton_Util {
22
		/**
23
		 * Le constructeur obligatoirement pour utiliser la classe \eoxia\Singleton_Util
24
		 *
25
		 * @return void nothing
26
		 */
27
		protected function construct() {}
28
29
		/**
30
		 * Renvoie la date au format SQL
31
		 *
32
		 * @param  string $date La date à formater.
33
		 * @return string      	La date formatée au format SQL
34
		 */
35
		public function formatte_date( $date ) {
36
			if ( strlen( $date ) === 10 ) {
37
				$date .= ' 00:00:00';
38
			}
39
40
			$date = str_replace( '/', '-', $date );
41
			$date = date( 'Y-m-d h:i:s', strtotime( $date ) );
42
			return $date;
43
		}
44
45
		public function mysqldate2wordpress( $date, $with_time = true ) {
46
			$format = get_option( 'date_format' );
47
			if ( $with_time ) {
48
				$format .= ' ' . get_option( 'time_format' );
49
			}
50
51
			return mysql2date( $format, $date );
52
		}
53
	}
54
} // End if().
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
55