Skip to content

Commit

Permalink
PHP Linting (Pint)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnovaro authored and github-actions[bot] committed Aug 4, 2023
1 parent 6018cd4 commit f8a7c7f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
3 changes: 1 addition & 2 deletions app/Console/Commands/ContactEmailPredictCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace App\Console\Commands;

use App\Helpers\PredictEmail;
use App\Models\Contact;
use Illuminate\Console\Command;
use App\Helpers\PredictEmail;

class ContactEmailPredictCommand extends Command
{
Expand Down Expand Up @@ -62,5 +62,4 @@ public function handle()

return Command::SUCCESS;
}

}
18 changes: 10 additions & 8 deletions app/Helpers/PredictEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@

class PredictEmail
{

public function predict(string $name, string $last_name, string $company_url): string | false
public function predict(string $name, string $last_name, string $company_url): string|false
{
$name = str_replace(' ', '', trim(strtolower($name)));
$last_name = str_replace(' ', '', trim(strtolower($last_name)));
$email = false;
$host = str_replace(['https://', 'http://','www.'],'', $company_url);
$host = str_replace(['https://', 'http://', 'www.'], '', $company_url);

// online
if ($socket = @fsockopen($host, 80, $errno, $errstr, 30)) {
Expand All @@ -32,20 +31,21 @@ public function predict(string $name, string $last_name, string $company_url): s
}
}
}

return $email;
}

public function fullNameWithDots(string $name, string $last_name, string $host) : string
public function fullNameWithDots(string $name, string $last_name, string $host): string
{
return $name.'.'.$last_name.'@'.$host;
}

public function firstLetterNameLastName(string $name, string $last_name, string $host) : string
public function firstLetterNameLastName(string $name, string $last_name, string $host): string
{
return substr($name, 0, 1).$last_name.'@'.$host;
}

public function nameOnly(string $name, string $host) : string
public function nameOnly(string $name, string $host): string
{
return substr($name, 0, 1).'@'.$host;
}
Expand All @@ -57,13 +57,15 @@ public function firstLettersOfNamesAndLastName(string $name, string $last_name,
foreach ($names as $n) {
$firstLetters .= substr($n, 0, 1);
}
return $firstLetters . $last_name . '@' . $host;

return $firstLetters.$last_name.'@'.$host;
}

public function isValid(string $email) : bool
public function isValid(string $email): bool
{
$rules = ['email' => 'email:rfc,dns'];
$validator = Validator::make(['email' => $email], $rules);

return $validator->passes();
}
}

0 comments on commit f8a7c7f

Please sign in to comment.