Inpsyde\MultilingualPress\Module\Exception\InvalidModuleException::for_id PHP Method

for_id() public static method

Returns a new exception object.
Since: 3.0.0
public static for_id ( string $id, string $action = 'read' ) : static
$id string Module ID.
$action string Optional. Action to be performed. Defaults to 'read'.
return static Exception object.
    public static function for_id($id, $action = 'read')
    {
        return new static(sprintf('Cannot %2$s "%1$s". There is no module with this ID.', $id, $action));
    }

Usage Example

 /**
  * Returns the module with the given ID.
  *
  * @since 3.0.0
  *
  * @param string $id Module ID.
  *
  * @return Module Module object.
  *
  * @throws InvalidModuleException if there is no module with the given ID.
  */
 public function get_module($id)
 {
     if (!$this->has_module($id)) {
         throw InvalidModuleException::for_id($id, 'read');
     }
     return $this->modules[$id];
 }
InvalidModuleException