Typescript   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 34
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A toJs() 0 19 2
1
<?php
2
3
/**
4
 * Manage Typescript 
5
 *
6
 * @category  	Venus
7
 * @package		Venus\lib
8
 * @author    	Judicaël Paquet <[email protected]>
9
 * @copyright 	Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93)
10
 * @license   	https://github.com/las93/venus2/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël
11
 * @version   	Release: 1.0.0
12
 * @filesource	https://github.com/las93/venus2
13
 * @link      	https://github.com/las93
14
 * @since     	1.0
15
 */
16
namespace Venus\lib;
17
18
/**
19
 * Manage Typescript
20
 *
21
 * @category  	Venus
22
 * @package		Venus\lib
23
 * @author    	Judicaël Paquet <[email protected]>
24
 * @copyright 	Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93)
25
 * @license   	https://github.com/las93/venus2/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël
26
 * @version   	Release: 1.0.0
27
 * @filesource	https://github.com/las93/venus2
28
 * @link      	https://github.com/las93
29
 * @since     	1.0
30
 */
31
class Typescript
32
{
33
    /**
34
     * @var string
35
     */
36
    const TYPESCRIPT_WINDOWS = TYPESCRIPT_WINDOWS;
37
    
38
	/**
39
	 * translate the content
40
	 *
41
	 * @access public
42
	 * @param  string $sFile
43
	 * @return string
44
	 */
45
	public static function toJs(string $sFile) : string
46
	{
47
	    $aFile = pathinfo($sFile);
48
	    $sFolder = uniqid();
49
	    
50
	    if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
51
	        
52
	        $sCmd = self::TYPESCRIPT_WINDOWS." ".$sFile." --outDir ".__DIR__.'../../'.CACHE_DIR.$sFolder.'/';
53
            $sContent = shell_exec($sCmd);
0 ignored issues
show
Unused Code introduced by
$sContent is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
54
	    }
55
	    else {
56
	       
57
	        $sCmd = "tsc ".$sFile." --outDir ".__DIR__.'../../'.CACHE_DIR.$sFolder.'/';
58
            $sContent = shell_exec($sCmd);
0 ignored issues
show
Unused Code introduced by
$sContent is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
59
	    }
60
	    
61
        header("content-type:text/javascript");
62
        return file_get_contents(__DIR__.'../../'.CACHE_DIR.$sFolder.'/'.$aFile['filename'].'.js');
63
	}
64
}
65