Skip to content

Instantly share code, notes, and snippets.

@oliverlundquist
Created October 7, 2015 01:24
Show Gist options
  • Save oliverlundquist/6e7caea5f7b2e4f4dfc0 to your computer and use it in GitHub Desktop.
Save oliverlundquist/6e7caea5f7b2e4f4dfc0 to your computer and use it in GitHub Desktop.
<?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());
@oliverlundquist
Copy link
Author

let's call $maxCount, $maxLimit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment