Merge pull request #5 from gianarb/remove-empty-control-line
Fixed #4 It doesn't print line if control value is empty
This commit is contained in:
commit
6e42141c12
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
<?php
|
||||
namespace wdm\debian\control;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Representation of Standard control file for Debian packages
|
||||
*
|
||||
* @author Walter Dal Mut
|
||||
* @package
|
||||
* @package
|
||||
* @license MIT
|
||||
*
|
||||
* Copyright (C) 2012 Corley S.R.L.
|
||||
|
@ -17,7 +17,7 @@ namespace wdm\debian\control;
|
|||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished to do
|
||||
* so, subject to the following conditions:
|
||||
*
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
|
@ -33,59 +33,59 @@ class StandardFile
|
|||
implements \ArrayAccess
|
||||
{
|
||||
private $_keys = array(
|
||||
'Package' => '',
|
||||
'Package' => false,
|
||||
'Version' => '0.1',
|
||||
"Section" => "web",
|
||||
"Priority" => "optional",
|
||||
"Architecture" => "all",
|
||||
"Essential" => "no",
|
||||
"Depends" => "",
|
||||
"Pre-Depends" => "",
|
||||
"Recommends" => "",
|
||||
"Suggests" => "",
|
||||
"Depends" => false,
|
||||
"Pre-Depends" => false,
|
||||
"Recommends" => false,
|
||||
"Suggests" => false,
|
||||
"Installed-Size" => 1024,
|
||||
"Maintainer" => "name [email]",
|
||||
"Conflicts" => "",
|
||||
"Replaces" => "",
|
||||
"Conflicts" => false,
|
||||
"Replaces" => false,
|
||||
"Provides" => "your-company",
|
||||
"Description" => "Your description"
|
||||
);
|
||||
|
||||
|
||||
public function setPackageName($name)
|
||||
{
|
||||
return $this->_setProperty("Package", $name);
|
||||
}
|
||||
|
||||
|
||||
public function setVersion($version)
|
||||
{
|
||||
return $this->_setProperty("Version", $version);
|
||||
}
|
||||
|
||||
|
||||
public function setSection($section)
|
||||
{
|
||||
return $this->_setProperty("Section", $section);
|
||||
}
|
||||
|
||||
|
||||
public function setPriority($priority)
|
||||
{
|
||||
return $this->_setProperty($this["Priority"], $priority);
|
||||
}
|
||||
|
||||
|
||||
public function setArchitecture($arch)
|
||||
{
|
||||
return $this->_setProperty("Architecture", $arch);
|
||||
}
|
||||
|
||||
|
||||
public function setEssential($essential)
|
||||
{
|
||||
return $this->_setProperty("Essential", $essential);
|
||||
}
|
||||
|
||||
|
||||
public function setDepends($depends)
|
||||
{
|
||||
return $this->_setProperty("Depends", $this->_transformList($depends));
|
||||
}
|
||||
|
||||
|
||||
public function setPreDepends($depends)
|
||||
{
|
||||
return $this->_setProperty("Pre-Depends", $this->_transformList($depends));
|
||||
|
@ -95,43 +95,43 @@ class StandardFile
|
|||
{
|
||||
return $this->_setProperty("Reccommends", $depends);
|
||||
}
|
||||
|
||||
|
||||
public function setSuggests($depends)
|
||||
{
|
||||
return $this->_setProperty("Suggests", $this->_transformList($depends));
|
||||
}
|
||||
|
||||
|
||||
public function setInstalledSize($size)
|
||||
{
|
||||
return $this->_setProperty("Installed-Size", $size);
|
||||
}
|
||||
|
||||
|
||||
public function setMaintainer($maintainer, $email = false)
|
||||
{
|
||||
$email = ($email) ? $email : "---";
|
||||
return $this->_setProperty("Maintainer", $maintainer . "[{$email}]");
|
||||
}
|
||||
|
||||
|
||||
public function setConflicts($conflicts)
|
||||
{
|
||||
return $this->_setProperty("Conflicts", $this->_transformList($conflicts));
|
||||
}
|
||||
|
||||
|
||||
public function setReplaces($replaces)
|
||||
{
|
||||
return $this->_setProperty("Conflicts", $this->_transformList($replaces));
|
||||
}
|
||||
|
||||
|
||||
public function setProvides($provides)
|
||||
{
|
||||
return $this->_setProperty("Provides", $provides);
|
||||
}
|
||||
|
||||
|
||||
public function setDescription($description)
|
||||
{
|
||||
return $this->_setProperty("Description", $description);
|
||||
}
|
||||
|
||||
|
||||
private function _transformList($depends)
|
||||
{
|
||||
if (is_array($depends)) {
|
||||
|
@ -139,16 +139,16 @@ class StandardFile
|
|||
} else {
|
||||
$depends = $depends;
|
||||
}
|
||||
|
||||
|
||||
return $depends;
|
||||
}
|
||||
|
||||
|
||||
private function _setProperty($key, $value)
|
||||
{
|
||||
$this[$key] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function offsetExists ($offset) {
|
||||
return array_key_exists($offset, $this->_keys);
|
||||
}
|
||||
|
@ -173,19 +173,21 @@ class StandardFile
|
|||
unset($this->_keys[$offset]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Control file string representation.
|
||||
*
|
||||
*
|
||||
* @return string The control file
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$control = '';
|
||||
foreach ($this->_keys as $key => $value) {
|
||||
$control .= "{$key}: {$value}" . PHP_EOL;
|
||||
if($value){
|
||||
$control .= "{$key}: {$value}" . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $control;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue