2017 © Pedro Peláez
 

library multiexception

This is a simple package for education purposes, that implements the concept of 'multiexceptions'

image

customer41/multiexception

This is a simple package for education purposes, that implements the concept of 'multiexceptions'

  • Wednesday, April 12, 2017
  • by customer41
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

MultiException

MultiException - это простой контейнер для ваших исключений, который сам по себе является исключением, (*1)

Требования

  • php >= 8.0

Установка

composer require customer41/multiexception, (*2)

Использование

setTitle($title);
        $this->setDescription($description);
        
        if (count($errors) > 0) {
            throw $errors;
        }
    }
    
    private function setTitle(string $title): void
    {
        if (!empty($title)) {
            $this->title = $title;
        } else {
            $errors->add(new \Exception('Пустой заголовок'));
        }
    }
    
    private function setDescription(string $description): void
    {
        if (!empty($description)) {
            $this->description = $description;
        } else {
            $errors->add(new \Exception('Пустое описание'));
        }
    }
}
```

В контроллере:
```php
class ArticleController
{
    public function createArticle(): void
    {
        try {
            $article = new Article($_POST['title'], $_POST['description']);
        } catch (MultiException $errors) {
            ...
        }
    }
}
```

В шаблоне:
```php

    <div class="alert alert-danger">
        <?php echo $error->getMessage(); ?>
    </div>

The Versions

12/04 2017

dev-master

9999999-dev

This is a simple package for education purposes, that implements the concept of 'multiexceptions'

  Sources   Download