Skip to content

Instantly share code, notes, and snippets.

View BoShurik's full-sized avatar

Alexander Borisov BoShurik

  • Amicus
  • Vladimir, Russia
View GitHub Profile
@BoShurik
BoShurik / ModelParameterResolver.php
Created May 8, 2024 21:16
Simple Yii ParametersResolver
<?php
namespace App\Model;
use App\Model\Attributes\FromBody;
use App\Model\Attributes\FromQuery;
use App\Model\Attributes\FromRequest;
use App\Model\Attributes\Model;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ServerRequestInterface;
@BoShurik
BoShurik / MadelineFactory.php
Last active March 28, 2024 04:19
Symfony MadelineProto Factory
<?php
namespace App\Madeline;
use danog\MadelineProto\API;
use danog\MadelineProto\Logger;
use danog\MadelineProto\Settings;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
@BoShurik
BoShurik / ConstraintDumper.php
Last active March 3, 2023 18:33
Dump Symfony Constraints
<?php
use Symfony\Component\Validator\Mapping\ClassMetadataInterface;
use Symfony\Component\Validator\Mapping\PropertyMetadata;
use Symfony\Component\Validator\Validator\ValidatorInterface;
class ConstraintDumper
{
public function __construct(private readonly ValidatorInterface $validator)
{
@BoShurik
BoShurik / PostModel.php
Created April 3, 2019 19:26
UniqueModel
namespace App\Post\Model;
use App\Model\Validator\Constraints\UniqueModel;
/**
* @UniqueModel(class="App\Entity\Post", fields={"user": "user", "slug": "slug"})
*/
class PostModel
{
public $user;
@BoShurik
BoShurik / Item.php
Last active November 20, 2018 20:10
automapper-issue
<?php
class Item
{
/**
* @var Value
*/
public $value;
public function __construct(Value $value)
@BoShurik
BoShurik / Color.php
Created February 21, 2018 10:18
Color value object
<?php
final class Color
{
private $name;
/**
* @param integer $r [0, 255]
* @param integer $g [0, 255]
* @param integer $b [0, 255]
* @return Color
<?php
namespace App;
use App\DependencyInjection\Configuration;
use App\DependencyInjection\FeedbackLoader;
use App\DependencyInjection\PagesLoader;
use App\DependencyInjection\YamlFileLoader;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Definition\Processor;
<?php
namespace AppBundle\Telegram\Command;
use BoShurik\TelegramBotBundle\Telegram\Command\AbstractCommand;
use TelegramBot\Api\BotApi;
use TelegramBot\Api\Types\Message;
class HelloWorldCommand extends AbstractCommand
{
@BoShurik
BoShurik / HTML.php
Last active November 11, 2023 20:35
PHPWord HTML
<?php
use PhpOffice\PhpWord\Element\AbstractContainer;
/**
* Common Html functions
*
* @SuppressWarnings(PHPMD.UnusedPrivateMethod) For readWPNode
*/
class Html
@BoShurik
BoShurik / FragmentPathResolver.php
Created July 5, 2016 16:19
Fragment path resolver to clear cache for widgets rendered by render_esi
<?php
namespace AppBundle\Cache;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Controller\ControllerReference;
use Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface;
class FragmentPathResolver
{