Package.php
public static function createFromLock(string $name, array $packageData): PackageContract
    {
        $keyToFunctionMappers = [
            'parent'          => 'setParentName',
            'is-dev'          => 'setIsDev',
            'url'             => 'setUrl',
            'operation'       => 'setOperation',
            'type'            => 'setType',
            'requires'        => 'setRequires',
            'automatic-extra' => 'setConfig',
            'autoload'        => 'setAutoload',
            'created'         => 'setTime',
        ];

        $package = new static($name, $packageData['version']);

        foreach ($packageData as $key => $data) {
            if ($data !== null && isset($keyToFunctionMappers[$key])) {
                $package->{$keyToFunctionMappers[$key]}($data);
            }
        }

        return $package;
    }
public static function createFromLock(string $name, array $packageData): PackageContract
    {
        $keyToFunctionMappers = [
            'parent'          => 'setParentName',
            'is-dev'          => 'setIsDev',
            'url'             => 'setUrl',
            'operation'       => 'setOperation',
            'type'            => 'setType',
            'requires'        => 'setRequires',
            'automatic-extra' => 'setConfig',
            'autoload'        => 'setAutoload',
            'created'         => 'setTime',
        ];

        $package = new static($name, $packageData['version']);

        foreach ($packageData as $key => $data) {
            if ($data !== null && isset($keyToFunctionMappers[$key])) {
                $package->{$keyToFunctionMappers[$key]}($data);
            }
        }

        return $package;
    }
public static function createFromLock ( string $ name , array $ packageData ) : PackageContract { $ keyToFunctionMappers = [ 'parent' => 'setParentName' , 'is-dev' => 'setIsDev' , 'url' => 'setUrl' , 'operation' => 'setOperation' , 'type' => 'setType' , 'requires' => 'setRequires' , 'automatic-extra' => 'setConfig' , 'autoload' => 'setAutoload' , 'created' => 'setTime' , ] ; $ package = new static ( $ name , $ packageData [ 'version' ] ) ; foreach ( $ packageData as $ key => $ data ) { if ( $ data !== null && isset ( $ keyToFunctionMappers [ $ key ] ) ) { $ package -> { $ keyToFunctionMappers [ $ key ] } ( $ data ) ; } } return $ package ; }
Create a automatic package from the lock data.

@param string $name
@param array  $packageData

@return \Narrowspark\Automatic\Common\Contract\Package
Create a automatic package from the lock data .