PHP code example of rayne / wz2008-graph

1. Go to this page and download the library: Download rayne/wz2008-graph library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rayne / wz2008-graph example snippets


use Rayne\wz2008\Graph\Factory\WzClassificationFactory;
use Rayne\wz2008\Graph\WzClassificationInterface;

/**
 * @var WzClassificationInterface $classification
 */

// Load the library's classification file …
$classification = WzClassificationFactory::build();

// … or load a custom classification file.
$classification = WzClassificationFactory::buildFromFile(
    'WZ2008-2016-07-29-Classification_(complete).xml');

use Rayne\wz2008\Graph\WzClassificationInterface;
use Rayne\wz2008\Graph\WzItemInterface;

/**
 * @var WzClassificationInterface $classification
 * @var WzItemInterface $item
 */

$id = '26.20.0';

if ($classification->has($id)) {
    $item = $classification->get($id);
}

use Rayne\wz2008\Graph\WzItemInterface;

/**
 * @var WzItemInterface $item
 * @var WzItemInterface|null $parent
 */

$parent = $item->getParent();

use Rayne\wz2008\Graph\WzItemInterface;

/**
 * @var WzItemInterface $item
 * @var WzItemInterface|null $parent
 */

$parent = $item->getParentByLevel($item::LEVEL_SECTION);

use Rayne\wz2008\Graph\WzItemInterface;

/**
 * @var WzItemInterface $item
 * @var WzItemInterface[] $children
 */

$children = $item->getChildren();

use Rayne\wz2008\Graph\WzItemInterface;

/**
 * @var WzItemInterface $item
 * @var WzItemInterface[] $children
 */

$children = $item->getChildrenByLevel($item::LEVEL_CLASS);

use Rayne\wz2008\Graph\WzClassificationInterface;
use Rayne\wz2008\Graph\WzItemInterface;

/**
 * @var WzClassificationInterface $classification 
 * @var WzItemInterface[] $sections
 */

$sections = $classification->getItemsByLevel(WzItemInterface::LEVEL_SECTION);

use Rayne\wz2008\Graph\WzItemInterface;

/**
 * @var WzItemInterface $item
 * @var string $label
 */

$label = $item->getLabel('de');

use Rayne\wz2008\Graph\WzItemInterface;

/**
 * @var WzItemInterface $item
 * @var string[] $labels
 */

$labels = $item->getLabels();

$labels = [
    'de' => 'Wirtschafts- und Arbeitgeberverbände',
    'en' => 'Activities of business and employers membership organisations',
];

use Rayne\wz2008\Graph\WzItemInterface;

/**
 * @var WzItemInterface $item
 */

$item->getId();

use Rayne\wz2008\Graph\WzItemInterface;

/**
 * @var WzItemInterface $item
 */

$item->getLevel();

    use Rayne\wz2008\Graph\Factory\WzClassificationFactory;
    use Rayne\wz2008\Graph\WzClassificationInterface;

    /**
    * @var WzClassificationInterface $classification
    */

    $classification = WzClassificationFactory::buildFromFile(
        'WZ2008-2016-07-29-Classification_(complete).xml');