phabel/src/PluginGraph/Graph.php

56 lines
1.1 KiB
PHP
Raw Normal View History

2020-08-05 14:52:49 +02:00
<?php
namespace Phabel\PluginGraph;
2020-08-09 13:49:19 +02:00
/**
* Graph API wrapper.
*/
2020-08-05 14:52:49 +02:00
class Graph
{
/**
2020-08-09 13:49:19 +02:00
* Graph instance.
2020-08-05 14:52:49 +02:00
*/
2020-08-09 13:49:19 +02:00
private GraphInternal $graph;
2020-08-05 14:52:49 +02:00
/**
2020-08-09 13:49:19 +02:00
* Constructr.
2020-08-05 14:52:49 +02:00
*/
2020-08-09 13:49:19 +02:00
public function __construct()
{
$this->graph = new GraphInternal;
}
2020-08-05 14:52:49 +02:00
/**
* Get new package context.
*
* @return PackageContext
*/
public function getPackageContext(): PackageContext
{
2020-08-09 13:49:19 +02:00
return $this->graph->getPackageContext();
2020-08-05 14:52:49 +02:00
}
/**
* Add plugin.
*
* @param string $plugin Plugin to add
* @param array $config Plugin configuration
* @param PackageContext $ctx Package context
*
* @psalm-param class-string<PluginInterface> $plugin Plugin name
*
* @return Node[]
*/
public function addPlugin(string $plugin, array $config, PackageContext $ctx): array
{
2020-08-09 13:49:19 +02:00
return $this->graph->addPlugin($plugin, $config, $ctx);
2020-08-05 14:52:49 +02:00
}
/**
2020-08-09 13:49:19 +02:00
* Flatten graph.
2020-08-05 14:52:49 +02:00
*
2020-08-09 13:49:19 +02:00
* @return SplQueue<SplQueue<Plugin>>
2020-08-05 14:52:49 +02:00
*/
2020-08-09 13:49:19 +02:00
public function flatten(): \SplQueue
2020-08-05 14:52:49 +02:00
{
2020-08-09 13:49:19 +02:00
return $this->graph->flatten();
2020-08-05 14:52:49 +02:00
}
}