[ create a new paste ] login | about

Project: fedecarg
Link: http://fedecarg.codepad.org/IZ7Tey4r    [ raw code | output | fork ]

PHP, pasted on Mar 2:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
class Book {
    private $id;
    private $title;

    static $belongsTo = 'Author';
    static $hasMany = array('authors'=>'Author');
    static $constraints = array('title'=>'maxSize:200');
   
    public function toArray() {
        return get_object_vars($this);
    }
}

$book = new Book();
var_dump($book->toArray());
var_dump(get_class_vars(get_class($book)));


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
array(2) {
  ["id"]=>
  NULL
  ["title"]=>
  NULL
}
array(3) {
  ["belongsTo"]=>
  string(6) "Author"
  ["hasMany"]=>
  array(1) {
    ["authors"]=>
    string(6) "Author"
  }
  ["constraints"]=>
  array(1) {
    ["title"]=>
    string(11) "maxSize:200"
  }
}


Create a new paste based on this one


Comments: