-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first and litle more attempt to build architecture of project
- Loading branch information
1 parent
cc533f6
commit c652286
Showing
5 changed files
with
54 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Hexlet\Code\Database; | ||
|
||
use PostgreSQLTutorial\FindUrl; | ||
|
||
class GetUrl | ||
{ | ||
/** | ||
* объект PDO | ||
* @var \PDO | ||
*/ | ||
private $pdo; | ||
|
||
|
||
public function __construct($pdo) | ||
{ | ||
$this->pdo = $pdo; | ||
} | ||
|
||
public function process() | ||
{ | ||
$sql = 'SELECT * | ||
FROM ad | ||
ORDER BY created_at DESC'; | ||
$sth = $this->pdo->prepare($sql); | ||
$sth->execute(); | ||
return $sth->fetchAll(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
class Validator | ||
{ | ||
public function validate(string $url): array | ||
{ | ||
$errors = []; | ||
if (strlen($url) > 255) { | ||
$errors['strlen'] = "Url must be less than 256 characters"; | ||
} elseif (!filter_var($url, FILTER_VALIDATE_URL)) { | ||
$errors['valid'] = 'URL is not valid'; | ||
} | ||
return $errors; | ||
} | ||
} |