Skip to content

Instantly share code, notes, and snippets.

@mattsches
mattsches / Roman.php
Created January 30, 2013 08:06
PHP Roman Numerals Code Kata solution. A collaborative effort of the people @ PHP User Group Rheinhessen, Jan '13.
<?php
/**
* Converts Roman numbers to integers
*/
class Roman
{
/**
* @var array
*/

Found an example there is a thing in laravel called FormRequest. Sometimes, I need extra validation. So I need to use some service there somehow. What options I have

  1. facade
  2. service locator via app() global function
  3. I also have instance of container there via $this->container

which one is the best here? I suppose instance of container

I can't do constructor injection. Why? Because for me, it seams that there are too many arguments on the __construct method

@mattsches
mattsches / configuration.yaml
Created May 8, 2017 21:35
Beispiel für RESTful Sensor in Home Assistant zur Abfrage des luftdaten.info API
sensor:
- platform: rest
resource: http://api.luftdaten.info/v1/sensor/1777
value_template: >
{% if value_json is sequence %}
{% set sensor = value_json | last %}
{% else %}
{% set sensor = value_json %}
{% endif %}
{% for sdv in sensor.sensordatavalues %}