weboAp/Option — pull request #3 by lokielse (2014-04-25 08:24:56+00:00)
Title: add group without prefix;change verify method;

1.migrations
```
$table->string('key', 50)->unique();
```
2.Option.php
```
private function verify($key = '')
{
if (empty($key) || !is_string($key)) {
throw new InvalidArgumentException('Invalid Option Key!');
}
$key = e(trim($key));
$key = strtolower($key);
$key = $this->toPrefix($key);
if (strlen($key) > 50) {
throw new InvalidArgumentException('Invalid Option Key Length, max=50!');
}
return $key;
}

private function toPrefix($key)
{
$prefix = \Config::get('option::default_prefix');
if (empty($prefix)) {
throw new Exception('default_prefix can not be empty');
}
if (!str_is('*.*', $key)) {
$key = sprintf('%s.%s', $prefix, $key);
}
return $key;
}
```
3.groupWithoutPrefix
```
public function getGroup($group, $withPrefix = true)
{
$all = $this->all();
$prefix = $group . '.';
if ($withPrefix) {
foreach ($all as $key => $value) {
if (!starts_with($key, $prefix)) {
unset($all[$key]);
}
}
} else {
$newAll = [];
foreach ($all as $key => $value) {
if (starts_with($key, $prefix)) {
$newKey = preg_replace("#^$prefix#", '', $key, 1);
$newAll[$newKey] = $value;
}
}
$all = $newAll;
}
return count($all) > 0 ? $all : null;
}
```