factory.php 678 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. *
  8. */
  9. namespace OC\L10N;
  10. /**
  11. * TODO: Description
  12. */
  13. class Factory {
  14. /**
  15. * cached instances
  16. */
  17. protected $instances = array();
  18. /**
  19. * get an L10N instance
  20. *
  21. * @param string $app
  22. * @param string|null $lang
  23. * @return \OC_L10N
  24. */
  25. public function get($app, $lang = null) {
  26. if (!is_null($lang)) {
  27. return new \OC_L10N($app, $lang);
  28. } else if (!isset($this->instances[$app])) {
  29. $this->instances[$app] = new \OC_L10N($app);
  30. }
  31. return $this->instances[$app];
  32. }
  33. }