ncc/src/ncc/Classes/PerlExtension/PerlRunner.php
Netkas 57009c115f
- Corrected code-smell and code style issues in \ncc\Objects > Package
- Corrected code-smell and code style issues in `\ncc\Classes\NccExtension > PackageCompiler`
 - Corrected code-smell and code style issues in `\ncc\CLI > PackageManagerMenu`
 - Corrected code-smell and code style issues in `\ncc\Classes\PhpExtension > PhpCompiler`
 - Corrected code-smell and code style issues in `\ncc\Classes\PhpExtension > PhpInstaller`
 - Corrected code-smell and code style issues in `\ncc\Classes\PhpExtension > PhpRunner`
 - Corrected code-smell and code style issues in `\ncc\Objects > ProjectConfiguraiton`
 - Corrected code-smell and code style issues in `\ncc\Managers > ProjectManager`
 - Corrected code-smell and code style issues in `\ncc\Classes\Extensions\PythonExtension > Python2Runner`
 - Corrected code-smell and code style issues in `\ncc\Classes\Extensions\PythonExtension > Python3Runner`
 - Corrected code-smell and code style issues in `\ncc\Classes\Extensions\PythonExtension > PythonRunner`
 - Corrected code-smell and code style issues in `\ncc\Interfaces > RunnerInterface`
2023-08-19 04:39:39 -04:00

68 lines
No EOL
2.5 KiB
PHP

<?php
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
namespace ncc\Classes\PerlExtension;
use ncc\Exceptions\AccessDeniedException;
use ncc\Exceptions\IOException;
use ncc\Exceptions\PathNotFoundException;
use ncc\Interfaces\RunnerInterface;
use ncc\Objects\Package\ExecutionUnit;
use ncc\Objects\ProjectConfiguration\ExecutionPolicy;
use ncc\Utilities\IO;
class PerlRunner implements RunnerInterface
{
/**
* @inheritDoc
* @param string $path
* @param ExecutionPolicy $policy
* @return ExecutionUnit
* @throws PathNotFoundException
* @throws AccessDeniedException
* @throws IOException
*/
public static function processUnit(string $path, ExecutionPolicy $policy): ExecutionUnit
{
$execution_unit = new ExecutionUnit();
$policy->Execute->Target = null;
if(!file_exists($path) && !is_file($path))
{
throw new PathNotFoundException($path);
}
$execution_unit->execution_policy = $policy;
$execution_unit->Data = IO::fread($path);
return $execution_unit;
}
/**
* @inheritDoc
*/
public static function getFileExtension(): string
{
return '.pl';
}
}