Created
October 7, 2015 01:24
-
-
Save oliverlundquist/6e7caea5f7b2e4f4dfc0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
trait MetaProperties { | |
public $limit = 0; | |
public function setLimit($limit) { | |
$this->limit = $limit <= $this->maxCount ? $limit : $this->maxCount; | |
} | |
public function getLimit() { | |
return $this->limit; | |
} | |
} | |
class Categories { | |
use MetaProperties; | |
public $maxCount = 100; | |
} | |
class Orders { | |
use MetaProperties; | |
public $maxCount = 1000; | |
} | |
$a = new Categories; | |
$a->setLimit(100); | |
var_dump($a->getLimit()); | |
$a = new Orders; | |
$a->setLimit(2000); | |
var_dump($a->getLimit()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
let's call $maxCount, $maxLimit