Skip to content

Instantly share code, notes, and snippets.

View kobus1998's full-sized avatar
😳
-10x programmer

Kobus kobus1998

😳
-10x programmer
View GitHub Profile
@kobus1998
kobus1998 / script.php
Created August 5, 2021 14:34
very useful program to sum a bit
<?php
$i = (fn($x) => (function ($x) {
return (fn($x) => $x + 1)($x + 1);
})($x + 1));
echo $i(1); // 4
@kobus1998
kobus1998 / MyApiClient.php
Last active August 3, 2021 14:34
simple api abstraction
<?php
class MyApiClient
{
use Requestor;
const VERSION = 'v1';
/** @var GuzzleHttp\Client */
private $client;
@kobus1998
kobus1998 / project-structure
Created July 30, 2021 07:12
example advanced project structure
use Rms\Domains\User\Commands\{ CreateUserCommand, CreateReservationHandler }
use Rms\App\Controllers\{ UserController, ReservationController}
src
- Domains
- User
- UserRepository.php
- UserEntity.php
- Commands
- CreateUserCommand.php
@kobus1998
kobus1998 / overheadPerformanceTest.php
Created June 11, 2021 08:09
overhead performance test
<?php
class mod {
public function __construct(private $aMod) {}
public function map($cCall) {
$this->aMod = array_map($cCall, $this->aMod);
return $this;
}
@kobus1998
kobus1998 / StrictSwitch.php
Created May 31, 2021 09:32
make a switch type check
<?php
class StrictSwitch
{
private $val;
private $done = false;
public function __construct($val)
{
@kobus1998
kobus1998 / test-using-dependency-injection.php
Last active May 14, 2021 13:30
test old code using dependency injection
<?php
interface Dep {
public function has();
}
// i want to test this function and get 100% code coverage
function depends(Dep $dependency) {
if ($dependency->has()) {
return true;
@kobus1998
kobus1998 / fuzzy-finder.php
Created May 11, 2021 13:26
fuzzy finder test
<?php
$aPages = [
'reservation', 'room type', 'room', 'rate type', 'rate availability', 'settings', 'connectivity'
];
$aTests = [
'rs', 'rt', 'rm', 'rat', 'ra', 'st', 'cnn'
];
@kobus1998
kobus1998 / calculation-structure.php
Created February 12, 2021 14:33
simple price calculation structure
<?php
class Price
{
public function getAmount(): int
{
return 0;
}
}
@kobus1998
kobus1998 / extendable-singleton.php
Created February 8, 2021 16:09
extendable singleton class
<?php
class Singleton
{
protected static $instanches = [];
private function __construct()
{
}
@kobus1998
kobus1998 / index.html
Created January 8, 2021 14:38
create custom html5 form rules
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form action="/" id="form">
<input type="text" fixed="abc" id="custom">