protected function generateDataType($dataType, array $data, $directory)
    {
        $dataType = $this->getDataTypeClassName($dataType);

        $class = new PhpClass();
        $class
            ->setQualifiedName('SecIT\\SchemaOrg\\Mapping\\DataType\\'.$dataType)
            ->setDescription('Class '.$dataType.'.')
            ->setMethod(PhpMethod::create('getSchemaUrl')
                ->setDescription('Get schema URL.')
                ->setType('string')
                ->setBody('return \''.$data['url'].'\';')
            )
        ;

        if ($data['ancestors']) {
            $class->setParentClassName($this->getDataTypeClassName(end($data['ancestors'])));
            $class->setDescription($class->getDescription()."\n\n".'@method '.$dataType.' setValue($value)');
        } else {
            $constructorBody = 'if ($value !== null) {'."\n";
            $constructorBody .= '   $this->setValue($value);'."\n";
            $constructorBody .= '}';

            $class
                ->addInterface($this->dataTypeInterfaceName)
                ->setProperty(PhpProperty::create('value')
                    ->setVisibility('private')
                    ->setType('string')
                )
                ->setMethod(PhpMethod::create('__construct')
                    ->setDescription($dataType.' constructor.')
                    ->addParameter(PhpParameter::create('value')
                        ->setType('string')
                        ->setValue(null)
                    )
                    ->setBody($constructorBody)
                )
                ->setMethod(PhpMethod::create('setValue')
                    ->setDescription('Set value.')
                    ->addParameter(PhpParameter::create('value')
                        ->setType('string')
                    )
                    ->setType($dataType)
                    ->setBody('$this->value = $value;'."\n\n".'return $this;')
                )
                ->setMethod(PhpMethod::create('getValue')
                    ->setDescription('Get value.')
                    ->setBody('return $this->value;')
                )
            ;
        }

        $generator = new CodeGenerator();
        $code = $generator->generate($class);

        file_put_contents($directory.$dataType.'.php', "<?php\n\n".$code);
    }