2017 © Pedro PelĂĄez
 

library wz2008-graph

Parses the "Classification of Economic Activities" (wz2008) issued by the Statistisches Bundesamt to build multiple hierarchically structured trees.

image

rayne/wz2008-graph

Parses the "Classification of Economic Activities" (wz2008) issued by the Statistisches Bundesamt to build multiple hierarchically structured trees.

  • Monday, July 16, 2018
  • by Rayne
  • Repository
  • 1 Watchers
  • 0 Stars
  • 53 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

Rayne/wz2008-graph

Rayne/wz2008-graph parses the "Classification of Economic Activities" issued by the Statistisches Bundesamt. It builds multiple hierarchically structured and object oriented in-memory trees from flat file structures with implicit hierarchy., (*1)

Latest Stable Version Latest Unstable Version Build Status Code Coverage Scrutinizer Code Quality License, (*2)

Rayne/wz2008-graph builds a tree structure, (*3)

Contents

Paketbeschreibung (German)

Diese Bibliothek extrahiert die implizit vorliegende hierarchische Branchen-Struktur aus der Klassifikation der Wirtschaftszweige, Ausgabe 2008 (WZ 2008). Als Daten-Grundlage wird die vollstÀndige Klassifikation als XML-Datei genutzt., (*4)

Die Klassifikation der Wirtschaftszweige, Ausgabe 2008 (WZ 2008), wurde unter intensiver Beteiligung von Datennutzern und Datenproduzenten in Verwaltung, Wirtschaft, Forschung und Gesellschaft geschaffen und dient dazu, die wirtschaftlichen TĂ€tigkeiten von Unternehmen, Betrieben und anderen statistischen Einheiten in allen amtlichen Statistiken einheitlich zu erfassen. Sie berĂŒcksichtigt die Vorgaben der statistischen Systematik der Wirtschaftszweige in der EuropĂ€ischen Gemeinschaft (NACE Rev. 2), die mit der Verordnung (EG) Nr. 1893/2006 des EuropĂ€ischen Parlaments und des Rates vom 20. Dezember 2006 (ABl. EG Nr. L 393 S. 1) veröffentlicht wurde und auf der International Standard Industrial Classification (ISIC Rev. 4) der Vereinten Nationen basiert. Die Zustimmung der EuropĂ€ischen Kommission gemĂ€ĂŸ Artikel 4, Absatz 3, der oben genannten Verordnung liegt vor., (*5)

Die Anwendung der WZ 2008 fĂŒr statistische Zwecke ergibt sich aus Artikel 8 der oben genannten Verordnung. Danach sind Statistiken, die sich auf vom 1. Januar 2008 an durchgefĂŒhrte WirtschaftstĂ€tigkeiten beziehen (Berichtsperiode), auf der Grundlage der NACE Rev. 2 (in Deutschland auf der Grundlage der WZ 2008) zu erstellen. Abweichend hiervon sind Konjunkturstatistiken gemĂ€ĂŸ der Verordnung (EG) Nr. 1165/98 und der Arbeitskostenindex gemĂ€ĂŸ der Verordnung (EG) Nr. 450/2003 ab dem 1. Januar 2009 auf Basis der NACE Rev. 2 (in Deutschland auf Basis der WZ 2008) zu erstellen. Die Anwendung ab 2008/2009 gilt nicht fĂŒr folgende Statistiken: Statistiken der Volkswirtschaftlichen Gesamtrechnungen gemĂ€ĂŸ der Verordnung (EG) Nr. 2223/96, die Landwirtschaftliche Gesamtrechnung gemĂ€ĂŸ der Verordnung (EG) Nr. 138/2004 und Statistiken der Zahlungsbilanz, des internationalen Dienstleistungsverkehrs und der Direktinvestitionen gemĂ€ĂŸ der Verordnung (EG) Nr. 184/2005. Diese Statistiken wenden die NACE Rev. 2 / WZ 2008 ab einem spĂ€teren Zeitpunkt an., (*6)

Quelle: https://www.klassifikationsserver.de/klassService/index.jsp?variant=wz2008, (*7)

Dependencies

Production

  • PHP 5.6 or better

Development

  • Composer
  • Git
  • PHPUnit

Licence

  • The library is published under the MIT licence., (*8)

  • The shipped /assets/WZ2008-[
].xml file is intellectual property of the Statistisches Bundesamt (Federal Statistical Office), Wiesbaden, Section „Classifications“., (*9)

    File content: Classification (complete)
    Further information: https://www.klassifikationsserver.de/
    Copyright: © Statistisches Bundesamt, Wiesbaden 2008 Distribution (also in parts) permitted, provided that the source is mentioned.
    Owner: Issued by: Statistisches Bundesamt (Federal Statistical Office), Wiesbaden, Section „Classifications“, Phone.: 0611/75-2510, -2294, -2280, Fax: 0611/75-3953,  E-Mail: wz@destatis.de
    Type: 'ex' = Part of (see help of the classification server)
    

Setup

Download Composer and install rayne/wz2008-graph., (*10)

composer require rayne/wz2008-graph

Alternatives, (*11)

Benchmarks

It is recommended to call the phpbench program directly instead of using the provided composer bench script. The latter will kill the benchmark after five minutes., (*12)

./vendor/bin/phpbench run

Tests

  1. Clone the repository, (*13)

    git clone https://github.com/rayne/wz2008-graph.git
    
  2. Install the development dependencies, (*14)

    composer install --dev --prefer-dist
    
  3. Run the tests, (*15)

    composer test
    

Usage

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');

Search WzItem by ID

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

Traverse WzItems

It's possible to traverse parents and children relative to a given WzItemInterface object. Every item has a hierarchy level between 1 and 5. WzItemInterface provides the following human readable constants., (*16)

DE EN Level Constant
Abschnitt Section 1 WzItemInterface::LEVEL_SECTION
Abteilung Division 2 WzItemInterface::LEVEL_DIVISION
Gruppe Group 3 WzItemInterface::LEVEL_GROUP
Klasse Class 4 WzItemInterface::LEVEL_CLASS
Unterklasse Subclass 5 WzItemInterface::LEVEL_SUBCLASS

Traverse Parents

Fetch the direct parent or traverse one level up., (*17)

use Rayne\wz2008\Graph\WzItemInterface;

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

$parent = $item->getParent();

Fetch the parent on a specific level or move up to a specific level., (*18)

use Rayne\wz2008\Graph\WzItemInterface;

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

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

Traverse Children

Fetch all direct children., (*19)

use Rayne\wz2008\Graph\WzItemInterface;

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

$children = $item->getChildren();

Fetch all children by a specific level. Children on other levels are skipped., (*20)

use Rayne\wz2008\Graph\WzItemInterface;

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

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

Filter WzItems by Level

Get all WzItemInterface items with a specific level., (*21)

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

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

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

Get translated Labels

WzItemInterface throws an InvalidArgumentException when there isn't a translation for the given language code. The official XML files are limited to DE and EN., (*22)

The $langCode of WzItemInterface->getLabel($langCode) is case-insensitive., (*23)

use Rayne\wz2008\Graph\WzItemInterface;

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

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

Get all translated labels and their language codes., (*24)

use Rayne\wz2008\Graph\WzItemInterface;

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

$labels = $item->getLabels();

WzItemInterface->getLabels() returns simple key (language code) value (translated label) maps., (*25)

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

Get WzItem ID

use Rayne\wz2008\Graph\WzItemInterface;

/**
 * @var WzItemInterface $item
 */

$item->getId();

Get WzItem Level

use Rayne\wz2008\Graph\WzItemInterface;

/**
 * @var WzItemInterface $item
 */

$item->getLevel();

Custom Data Sets

  1. Download a WZ2008-20XX-XX-XX-Classification_(complete).xml file, (*26)

    1. Visit klassifikationsserver.de/klassService/index.jsp?variant=wz2008, (*27)

    2. Locate the ZIP download in the download matrix at position, (*28)

      ("Klassifikation komplett", "XML (Claset)")
      
    3. Extract the downloaded ZIP file, (*29)

  2. Use the factory to build a WzClassificationInterface object based upon the downloaded XML file, (*30)

    use Rayne\wz2008\Graph\Factory\WzClassificationFactory;
    use Rayne\wz2008\Graph\WzClassificationInterface;
    
    /**
    * @var WzClassificationInterface $classification
    */
    
    $classification = WzClassificationFactory::buildFromFile(
        'WZ2008-2016-07-29-Classification_(complete).xml');
    

The Versions

16/07 2018

dev-master

9999999-dev

Parses the "Classification of Economic Activities" (wz2008) issued by the Statistisches Bundesamt to build multiple hierarchically structured trees.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Dennis Meckel

tree graph wz2008 wirtschaftszweige nace naics isic statistisches-bundesamt

16/07 2018

dev-dev

dev-dev

Parses the "Classification of Economic Activities" (wz2008) issued by the Statistisches Bundesamt to build multiple hierarchically structured trees.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Dennis Meckel

tree graph wz2008 wirtschaftszweige nace naics isic statistisches-bundesamt

16/07 2018

1.1.1

1.1.1.0

Parses the "Classification of Economic Activities" (wz2008) issued by the Statistisches Bundesamt to build multiple hierarchically structured trees.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Dennis Meckel

tree graph wz2008 wirtschaftszweige nace naics isic statistisches-bundesamt

19/05 2017

1.1.0

1.1.0.0

Parses the "Classification of Economic Activities" (wz2008) issued by the Statistisches Bundesamt to build multiple hierarchically structured trees.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Dennis Meckel

tree graph wz2008 wirtschaftszweige nace naics isic statistisches-bundesamt

10/03 2017

dev-benchmarks

dev-benchmarks

Parses the "Classification of Economic Activities" (wz2008) issued by the Statistisches Bundesamt to build multiple hierarchically structured trees.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Dennis Meckel

tree graph wz2008 wirtschaftszweige nace naics isic statistisches-bundesamt

20/02 2017

1.0.1

1.0.1.0

Parses the "Classification of Economic Activities" (wz2008) issued by the Statistisches Bundesamt to build multiple hierarchically structured trees.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Dennis Meckel

tree graph wz2008 wirtschaftszweige nace naics isic statistisches-bundesamt

14/02 2017

1.0.0

1.0.0.0

Parses the "Classification of Economic Activities" (wz2008) issued by the Statistisches Bundesamt to build multiple hierarchically structured trees.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Dennis Meckel

tree graph wz2008

13/02 2017

1.0.0-rc2

1.0.0.0-RC2

Parses the "Classification of Economic Activities" (wz2008) issued by the Statistisches Bundesamt to build multiple hierarchically structured trees.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Dennis Meckel

tree graph wz2008

05/02 2017

1.0.0-rc1

1.0.0.0-RC1

Parses the "Classification of Economic Activities" (wz2008) issued by the Statistisches Bundesamt to build multiple hierarchically structured trees.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Dennis Meckel

tree graph wz2008