php-pharlite/src/ManifestObject.php

46 lines
885 B
PHP

<?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);
}
}