Initial commit

This commit is contained in:
2018-04-06 01:22:42 +02:00
commit fd5b3ddb8f
7 changed files with 514 additions and 0 deletions

46
src/ManifestObject.php Normal file
View File

@ -0,0 +1,46 @@
<?php
namespace PharLite;
/**
* Class representing a single object to be added to a phar
*
*
*/
class ManifestObject
{
protected $filename;
protected $localname;
public function __construct($filename, $localname=null)
{
$this->filename = $filename;
$this->localname = $localname;
}
public function getFilename()
{
return $this->filename;
}
public function getLocalName()
{
return $this->localname;
}
public function addToPhar(\Phar $phar)
{
$phar->addFile(
$this->getFilename(),
$this->getLocalName()
);
}
public function addFiltered(\Phar $phar, callable $filter)
{
$body = file_get_contents($this->filename);
$body = call_user_func($filter, $body);
$phar->addFromString($this->getLocalName(), $body);
}
}