Skip to content

Instantly share code, notes, and snippets.

View suin's full-sized avatar
😃

suin

😃
View GitHub Profile
.
├── src
│   └── MyCompany
│   └── AppBundle
│   ├── Command
│   └── Controller
└── vendor
└── MyCompany
├── DataSourceModule1
│   ├── ExternalService
<?php
class Foo
{
private $foo = 'bar';
public function generate()
{
return function() {
return $this->foo;
@suin
suin / test.php
Created December 2, 2012 07:43
parent::parent::parentコンストラクタパターン
<?php
class Foo
{
public function __construct()
{
$this->value = __CLASS__;
}
}
@suin
suin / Assertion.php
Created November 29, 2012 04:29
Assertionフレームワークのプロトタイプ(案)
<?php
class Assertion
{
private $assertion;
private $valiator;
public function __construct($assertion, callable $validator)
{
fields:
name:
type: string
label: "契約者名"
uname:
type: string
lablel: "ユーザ名"
email:
type: string
label: "メールアドレス"
@suin
suin / datetme.php
Created November 27, 2012 05:47
PHPのDateTimeクラスが作り方によって色々違う
<?php
$date1 = new DateTime('@999994149');
$date2 = (new DateTime)->setTimestamp(999994149);
var_dump($date1->getTimestamp());
var_dump($date2->getTimestamp());
$diff = $date1->diff($date2);
@suin
suin / Entity.php
Created November 16, 2012 06:15
PHP5.3のクラスエイリアシングを使った型下位互換技術
<?php
namespace XCore\Entity;
class User
{
// 元XoopsUserクラス
}
class Module
@suin
suin / Test.java
Created November 11, 2012 12:59
PHPは引数型のダウンキャストができないなと思ったら。
class Test {
public static void main(String[] args) {
UserRepository userRepository = new UserRepository();
userRepository.persist(new Object());
userRepository.persist(new User());
}
}
class Repository
{
@suin
suin / gist:3923273
Created October 20, 2012 13:27
test 1
{
    "require": {
        "friendsofsymfony/facebook-bundle": "*"
    },
    "minimum-stability": "stable"
}
<?php
/**
* ポリシーエンティティのモック
*/
class Policy
{
/**
* @return DateTime
*/