static public function createInDirectory($dir)
    {
        if (! is_dir($dir) || ! is_writable($dir)) {
            throw new \InvalidArgumentException("Directory to load build number from is not writable or does not exist: " . $dir);
        }
        
        $buildFile = $dir . DIRECTORY_SEPARATOR . "azure_build_number.yml";
        
        if (! file_exists($buildFile)) {
            file_put_contents($buildFile, "parameters:\n  azure_build: 0");
        }
        
        return new self($buildFile);
    }