src/SharedKernel/ApplicationDataTypeLocation.php
public function addDataTypeClass($dataTypeFQCN, $classContent, $replace = false)
    {
        if (strpos($dataTypeFQCN, "Prooph\\Link\\Application\\DataType\\") !== 0) {
            throw new \InvalidArgumentException("Namespace of data type should start with Prooph\\Link\\Application\\DataType\\. Got " . $dataTypeFQCN);
        }
        $nsDirs = explode("\\", str_replace("Prooph\\Link\\Application\\DataType\\", "", $dataTypeFQCN));

        $className = array_pop($nsDirs);

        if (empty($className)) {
            throw new \InvalidArgumentException("Provided data type FQCN contains no class name: " . $dataTypeFQCN);
        }

        $currentPath = $this->toString();

        if (! empty($nsDirs)) {
            foreach ($nsDirs as $nsDir) {
                $currentPath .= DIRECTORY_SEPARATOR . $nsDir;
                if (! is_dir($currentPath)) mkdir($currentPath);
            }
        }

        $filename = $currentPath . DIRECTORY_SEPARATOR . $className . ".php";

        if (!$replace && file_exists($filename)) return;

        file_put_contents($filename, $classContent);
    }
public function addDataTypeClass($dataTypeFQCN, $classContent, $replace = false)
    {
        if (strpos($dataTypeFQCN, "Prooph\\Link\\Application\\DataType\\") !== 0) {
            throw new \InvalidArgumentException("Namespace of data type should start with Prooph\\Link\\Application\\DataType\\. Got " . $dataTypeFQCN);
        }
        $nsDirs = explode("\\", str_replace("Prooph\\Link\\Application\\DataType\\", "", $dataTypeFQCN));

        $className = array_pop($nsDirs);

        if (empty($className)) {
            throw new \InvalidArgumentException("Provided data type FQCN contains no class name: " . $dataTypeFQCN);
        }

        $currentPath = $this->toString();

        if (! empty($nsDirs)) {
            foreach ($nsDirs as $nsDir) {
                $currentPath .= DIRECTORY_SEPARATOR . $nsDir;
                if (! is_dir($currentPath)) mkdir($currentPath);
            }
        }

        $filename = $currentPath . DIRECTORY_SEPARATOR . $className . ".php";

        if (!$replace && file_exists($filename)) return;

        file_put_contents($filename, $classContent);
    }
public function addDataTypeClass ( $ dataTypeFQCN , $ classContent , $ replace = false ) { if ( strpos ( $ dataTypeFQCN , "Prooph\\Link\\Application\\DataType\\" ) !== 0 ) { throw new \ InvalidArgumentException ( "Namespace of data type should start with Prooph\\Link\\Application\\DataType\\. Got " . $ dataTypeFQCN ) ; } $ nsDirs = explode ( "\\" , str_replace ( "Prooph\\Link\\Application\\DataType\\" , "" , $ dataTypeFQCN ) ) ; $ className = array_pop ( $ nsDirs ) ; if ( empty ( $ className ) ) { throw new \ InvalidArgumentException ( "Provided data type FQCN contains no class name: " . $ dataTypeFQCN ) ; } $ currentPath = $ this -> toString ( ) ; if ( ! empty ( $ nsDirs ) ) { foreach ( $ nsDirs as $ nsDir ) { $ currentPath .= DIRECTORY_SEPARATOR . $ nsDir ; if ( ! is_dir ( $ currentPath ) ) mkdir ( $ currentPath ) ; } } $ filename = $ currentPath . DIRECTORY_SEPARATOR . $ className . ".php" ; if ( ! $ replace && file_exists ( $ filename ) ) return ; file_put_contents ( $ filename , $ classContent ) ; }
Writes the given class content to a class file named after the class.
The root directory is defined by the path of ApplicationDataTypeLocation.
The namespace of the class should start with Application\DataType\
If more sub namespaces are defined, the method creates a directory for each
namespace part if not already exists.

By default a new class is only generated if it does not exist already.
You can force an override by setting the replace flag to true.

@param $dataTypeFQCN
@param $classContent
@param bool $replace
@throws \InvalidArgumentException
Writes the given class content to a class file named after the class . The root directory is defined by the path of ApplicationDataTypeLocation . The namespace of the class should start with Application \ DataType \ If more sub namespaces are defined the method creates a directory for each namespace part if not already exists .