Skip to content

Commit

Permalink
same as previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-xz committed Feb 19, 2024
1 parent defb220 commit 0cc2e7b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/FilesProcessing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Differ\FilesProcessing;

function makePathAbsolute(string $pathToFile)
{
$realPath = realpath($pathToFile);
if ($realPath === false) {
$absolutePath = __DIR__ . $pathToFile;
} else {
$absolutePath = $realPath;
}
return $absolutePath;
}

function getFilesContent(string $absolutePath)
{
if (!file_exists($absolutePath)) {
throw new \Exception("File do not found: \"{$absolutePath}\"!");
} elseif (filesize($absolutePath) == 0) {
$pathBaseName = pathinfo($absolutePath, PATHINFO_BASENAME);
throw new \Exception("File \"{$pathBaseName}\" is empty.");
}
return file_get_contents($absolutePath, true);
}

0 comments on commit 0cc2e7b

Please sign in to comment.