1: <?php
2:
3: namespace Guzzle\Inflection;
4:
5: /**
6: * Default inflection implementation
7: */
8: class Inflector implements InflectorInterface
9: {
10: /**
11: * @var InflectorInterface
12: */
13: protected static $default;
14:
15: /**
16: * Get the default inflector object that has support for caching
17: *
18: * @return MemoizingInflector
19: */
20: public static function getDefault()
21: {
22: // @codeCoverageIgnoreStart
23: if (!self::$default) {
24: self::$default = new MemoizingInflector(new self());
25: }
26: // @codeCoverageIgnoreEnd
27:
28: return self::$default;
29: }
30:
31: /**
32: * {@inheritdoc}
33: */
34: public function snake($word)
35: {
36: return ctype_lower($word) ? $word : strtolower(preg_replace('/(.)([A-Z])/', "$1_$2", $word));
37: }
38:
39: /**
40: * {@inheritdoc}
41: */
42: public function camel($word)
43: {
44: return str_replace(' ', '', ucwords(strtr($word, '_-', ' ')));
45: }
46: }
47: