mirror of
https://github.com/composer/composer
synced 2025-05-11 09:32:55 +00:00
Implemented ArrayDumper
This commit is contained in:
parent
20318f77a0
commit
5890b05eb0
1 changed files with 58 additions and 0 deletions
58
src/Composer/Package/Dumper/ArrayDumper.php
Normal file
58
src/Composer/Package/Dumper/ArrayDumper.php
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Composer.
|
||||||
|
*
|
||||||
|
* (c) Nils Adermann <naderman@naderman.de>
|
||||||
|
* Jordi Boggiano <j.boggiano@seld.be>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Composer\Package\Dumper;
|
||||||
|
|
||||||
|
use Composer\Package\PackageInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Konstantin Kudryashiv <ever.zet@gmail.com>
|
||||||
|
*/
|
||||||
|
class ArrayDumper
|
||||||
|
{
|
||||||
|
public function dump(PackageInterface $package)
|
||||||
|
{
|
||||||
|
$keys = array(
|
||||||
|
'type',
|
||||||
|
'names',
|
||||||
|
'extra',
|
||||||
|
'installationSource',
|
||||||
|
'sourceType',
|
||||||
|
'sourceUrl',
|
||||||
|
'distType',
|
||||||
|
'distUrl',
|
||||||
|
'distSha1Checksum',
|
||||||
|
'releaseType',
|
||||||
|
'version',
|
||||||
|
'license',
|
||||||
|
'requires',
|
||||||
|
'conflicts',
|
||||||
|
'provides',
|
||||||
|
'replaces',
|
||||||
|
'recommends',
|
||||||
|
'suggests'
|
||||||
|
);
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
$data['name'] = $package->getPrettyName();
|
||||||
|
foreach ($keys as $key) {
|
||||||
|
$getter = 'get'.ucfirst($key);
|
||||||
|
$value = $package->$getter();
|
||||||
|
|
||||||
|
if (null !== $value && !(is_array($value) && 0 === count($value))) {
|
||||||
|
$data[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue