Passed
Push — master ( 505ae7...78ca0f )
by Jip
03:42
created

Stencil_Installable_Versions   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 50
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B get() 0 17 5
1
<?php
2
/**
3
 * Seperate place to keep track of latest versions
4
 *
5
 * @package Stencil
6
 * @subpackage Upgrader
7
 */
8
9
/**
10
 * Class Stencil_Installable_Versions
11
 */
12
class Stencil_Installable_Versions {
13
	/**
14
	 * Latest versions
15
	 *
16
	 * @var array
17
	 */
18
	private static $versions = array(
19
		'plugins' => array(
20
			'stencil'          => '1.0.0',
21
			'stencil-dwoo2'    => '1.0.0',
22
			'stencil-mustache' => '1.0.0',
23
			'stencil-savant3'  => '1.0.0',
24
			'stencil-smarty2'  => '1.0.0',
25
			'stencil-smarty3'  => '1.0.0',
26
			'stencil-twig'     => '1.0.0',
27
		),
28
		'themes'  => array(
29
			'dwoo2'    => '1.0.0',
30
			'mustache' => '1.0.0',
31
			'savant'   => '1.0.0',
32
			'smarty'   => '1.0.0',
33
			'twig'     => '1.0.0',
34
		),
35
	);
36
37
	/**
38
	 * Get version for installable
39
	 *
40
	 * @param Stencil_Installable_Interface $installable Installable to get version of.
41
	 *
42
	 * @return string
43
	 */
44
	public static function get( Stencil_Installable_Interface $installable ) {
45
		$slug = $installable->get_slug();
46
47
		if ( is_a( $installable, 'Stencil_Installable_Plugin' ) ) {
48
			if ( isset( self::$versions['plugins'][ $slug ] ) ) {
49
				return self::$versions['plugins'][ $slug ];
50
			}
51
		}
52
53
		if ( is_a( $installable, 'Stencil_Installable_Theme' ) ) {
54
			if ( isset( self::$versions['themes'][ $slug ] ) ) {
55
				return self::$versions['themes'][ $slug ];
56
			}
57
		}
58
59
		return '0.0.0';
60
	}
61
}
62