Загрузить файлы в «src/traits»
This commit is contained in:
16
src/traits/CreateOption.php
Normal file
16
src/traits/CreateOption.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace src\traits;
|
||||||
|
|
||||||
|
trait CreateOption
|
||||||
|
{
|
||||||
|
public function createOption(array $options, $value = null): string
|
||||||
|
{
|
||||||
|
$optionsString = "";
|
||||||
|
foreach ($options as $val => $title){
|
||||||
|
$selected = $value === $val ? "selected" : "";
|
||||||
|
$optionsString .= "<option $selected value='$val'>$title</option>";
|
||||||
|
}
|
||||||
|
return $optionsString;
|
||||||
|
}
|
||||||
|
}
|
22
src/traits/CreateParams.php
Normal file
22
src/traits/CreateParams.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace src\traits;
|
||||||
|
|
||||||
|
trait CreateParams
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function createParams(array $data = []): string
|
||||||
|
{
|
||||||
|
$paramsString = "";
|
||||||
|
foreach($data as $key => $param){
|
||||||
|
$paramsString .= $key . "='" . $param . "'";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $paramsString;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user