PackageJson
        
        PHP based interface for interacting with package.json files. This allows for modification of deps, devDeps, package
name and workspaces.
    
    
 class System\Classes\Asset\PackageJsonProperties
protected $data : array
The contents of the package.json being modified
Methods
            
            
            
                public
            
                        
            __construct ($path = null)
                    
        
        Create a new instance with optional path, loads file if file already exists
| Property | Type | Description | 
|---|---|---|
| $path | mixed | mixed | 
            
            
            
                public
            
                        
            addDependency (string $package, string $version, boolean $dev = false, boolean $overwrite = false)
                            : static
                    
        
        Adds a dependency, supports adding to dependencies or devDependencies based on $dev and allows moving if
$overwrite is set
| Property | Type | Description | 
|---|---|---|
| $package | string | string | 
| $version | string | string | 
| $dev | boolean | boolean | 
| $overwrite | boolean | boolean | 
public addIgnoredPackage (string $path) : static
Adds an ignored package, removes from workspaces if present
| Property | Type | Description | 
|---|---|---|
| $path | string | string | 
public addScript (string $name, string $script) : static
Adds a script
| Property | Type | Description | 
|---|---|---|
| $name | string | string | 
| $script | string | string | 
public addWorkspace (string $path) : static
Adds a new workspace, removes from ignored workspaces if present
| Property | Type | Description | 
|---|---|---|
| $path | string | string | 
public getContents () : array
Returns the package.json contents as an array
public getName () : string | null
Returns the package name if set
public getPath () : string | null
Returns the path of the package.json if set
public getScript (string $name) : string | null
Returns the value of a script by name
| Property | Type | Description | 
|---|---|---|
| $name | string | string | 
public hasDependency (string $package) : bool
Checks if package.json has a dependency
| Property | Type | Description | 
|---|---|---|
| $package | string | string | 
public hasIgnoredPackage (string $path) : bool
Check if package is ignored
| Property | Type | Description | 
|---|---|---|
| $path | string | string | 
public hasScript (string $name) : bool
Returns if a script exists
| Property | Type | Description | 
|---|---|---|
| $name | string | string | 
public hasWorkspace (string $path) : bool
Checks if workspace package is set
| Property | Type | Description | 
|---|---|---|
| $path | string | string | 
public removeDependency (string $package) : static
Removes a package from both dependencies and devDependencies
| Property | Type | Description | 
|---|---|---|
| $package | string | string | 
public removeIgnoredPackage (string $path) : static
Removes an ignored package
| Property | Type | Description | 
|---|---|---|
| $path | string | string | 
public removeScript (string $name) : static
Removes a script by name
| Property | Type | Description | 
|---|---|---|
| $name | string | string | 
public removeWorkspace (string $path) : static
Removes a workspace
| Property | Type | Description | 
|---|---|---|
| $path | string | string | 
            
            
            
                public
            
                        
            save ($path = null)
                            : integer
                    
        
        Saves the contents to a file, if the object was init'ed with a path it will save to the path, or can be
overwritten with $path.
| Property | Type | Description | 
|---|---|---|
| $path | mixed | mixed | 
public setName (string | null $name) : static
Sets the package name, throws InvalidArgumentException on invalid name
| Property | Type | Description | 
|---|---|---|
| $name | string | null | string | null |