Completed
Push — master ( c2e541...ef0b75 )
by Emlyn
03:51 queued 02:00
created

RoboFile   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A createPhar() 0 39 2
1
<?php
2
/**
3
 * PHP Version 5.6
4
 * @category Library
5
 * @package  ChangeLog
6
 * @author   Emlyn West <[email protected]>
7
 * @license  MIT http://opensource.org/licenses/MIT
8
 * @link     https://github.com/emlynwest/changelog
9
 */
10
11
use Robo\Tasks;
12
use Symfony\Component\Finder\Finder;
13
14
class RoboFile extends Tasks
15
{
16
	public function createPhar()
17
	{
18
		$collection = $this->collection();
19
20
		$this->taskComposerInstall()
21
			->noDev()
22
			->optimizeAutoloader()
23
			->printed(false)
24
			->addToCollection($collection);
25
26
		$packer = $this->taskPackPhar('package/changelog.phar')
27
			->compress(true)
28
			->stub('package/stub.php');
29
30
		$files = Finder::create()
31
			->ignoreVCS(true)
32
			->files()
33
			->name('*.php')
34
			->path('src')
35
			->path('vendor')
36
			->in(__DIR__);
37
38
		foreach ($files as $file) {
39
			$packer->addFile($file->getRelativePathname(), $file->getRealPath());
40
		}
41
42
		@unlink('package/bin');
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
43
		@unlink('package/changelog.phar');
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
44
		copy('changelog', 'package/bin');
45
46
		$packer->addFile('changelog', 'package/bin')
47
			->addToCollection($collection);
48
49
		$this->taskComposerInstall()
50
			 ->printed(false)
51
			 ->addToCollection($collection);
52
53
		$collection->run();
54
	}
55
}
56