Skip to content

Commit

Permalink
Applied code style suggestions from the bot
Browse files Browse the repository at this point in the history
  • Loading branch information
mnocon committed Oct 27, 2023
1 parent 9ad4233 commit 042764b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Configurator/AddLinesConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private function getPatchedContents(string $file, string $value, string $positio
{
$fileContents = $this->readFile($file);

if (false !== strpos($fileContents, $value)) {
if (str_contains($fileContents, $value)) {
return $fileContents; // already includes value, skip
}

Expand All @@ -185,7 +185,7 @@ private function getPatchedContents(string $file, string $value, string $positio
$lines = explode("\n", $fileContents);
$targetFound = false;
foreach ($lines as $key => $line) {
if (false !== strpos($line, $target)) {
if (str_contains($line, $target)) {
array_splice($lines, $key + 1, 0, $value);
$targetFound = true;

Expand Down Expand Up @@ -214,14 +214,14 @@ private function getUnPatchedContents(string $file, $value): string
{
$fileContents = $this->readFile($file);

if (false === strpos($fileContents, $value)) {
if (!str_contains($fileContents, $value)) {
return $fileContents; // value already gone!
}

if (false !== strpos($fileContents, "\n".$value)) {
if (str_contains($fileContents, "\n".$value)) {
$value = "\n".$value;
} elseif (false !== strpos($fileContents, $value."\n")) {
$value = $value."\n";
} elseif (str_contains($fileContents, $value."\n")) {
$value .= "\n";
}

$position = strpos($fileContents, $value);
Expand Down Expand Up @@ -249,7 +249,7 @@ private function isPackageInstalled($packages): bool
private function relativize(string $path): string
{
$rootDir = $this->options->get('root-dir');
if (0 === strpos($path, $rootDir)) {
if (str_starts_with($path, $rootDir)) {
$path = substr($path, \strlen($rootDir) + 1);
}

Expand Down

0 comments on commit 042764b

Please sign in to comment.