Tidy up PHP code

Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
2024-10-29 16:14:29 -07:00
parent 5d4863f9be
commit 4f1ff35194
3 changed files with 332 additions and 327 deletions

View File

@@ -5,19 +5,19 @@ use ImageHandler;
use Html;
class GlModelHandler extends ImageHandler {
/**
* Model cannot be displayed directly in a browser but can be rendered.
*
* @param File $file
* @return bool
*/
public function mustRender( $file ) {
return true;
}
/**
* Model cannot be displayed directly in a browser but can be rendered.
*
* @param File $file
* @return bool
*/
public function mustRender( $file ) {
return true;
}
/**
* Model can be rendered.
*
/**
* Model can be rendered.
*
* @param File $file
* @return bool
*/
@@ -25,53 +25,53 @@ class GlModelHandler extends ImageHandler {
return true;
}
/**
* Get a MediaTransformOutput object representing the transformed output.
*
* @param File $image
* @param string $dstPath Filesystem destination path
* @param string $dstUrl Destination URL to use in output HTML
* @param array $params Arbitrary set of parameters validated by $this->validateParam()
* @param int $flags A bitfield, may contain self::TRANSFORM_LATER
* @return MediaTransformOutput
*/
public function doTransform($image, $dstPath, $dstUrl, $params, $flags = 0) {
return new GlModelTransformOutput($image, $params);
}
/**
* Get a MediaTransformOutput object representing the transformed output.
*
* @param File $image
* @param string $dstPath Filesystem destination path
* @param string $dstUrl Destination URL to use in output HTML
* @param array $params Arbitrary set of parameters validated by $this->validateParam()
* @param int $flags A bitfield, may contain self::TRANSFORM_LATER
* @return MediaTransformOutput
*/
public function doTransform($image, $dstPath, $dstUrl, $params, $flags = 0) {
return new GlModelTransformOutput($image, $params);
}
/**
* Check the incoming media parameters
*
/**
* Check the incoming media parameters
*
* @param string $name
* @param string $value
* @return bool
*/
public function validateParam( $name, $value ) {
if (in_array($name, ['width', 'height'])) {
return $value > 0;
} else if (in_array($name, ['view', 'hsset'])) {
return true;
} else {
return false;
if (in_array($name, ['width', 'height'])) {
return $value > 0;
} else if (in_array($name, ['view', 'hsset'])) {
return true;
} else {
return false;
}
}
}
/**
* Small helper function to display information on the browser console
*
* Usage:
* echo '<script>';
* self::console_log('logged string');
* echo '</script>';
*
* @param $data information to display
* @param bool $add_script_tags true to put information is inside complete script tag
*/
public static function console_log($data, $add_script_tags = false) {
$command = 'console.log('. json_encode($data, JSON_HEX_TAG).');';
if ($add_script_tags) {
$command = '<script>'. $command . '</script>';
/**
* Small helper function to display information on the browser console
*
* Usage:
* echo '<script>';
* self::console_log('logged string');
* echo '</script>';
*
* @param $data information to display
* @param bool $add_script_tags true to put information is inside complete script tag
*/
public static function console_log($data, $add_script_tags = false) {
$command = 'console.log('. json_encode($data, JSON_HEX_TAG).');';
if ($add_script_tags) {
$command = '<script>'. $command . '</script>';
}
echo $command;
}
echo $command;
}
}