Generate a plural name based on the passed in root.

@param  string $root The root that needs to be pluralized (e.g. Author)
@return string The plural form of $root (e.g. Authors).
@throws \InvalidArgumentException If the parameter is not a string.
978734
public function getPluralForm($root) {
		$pluralForm = $root;

		if (!is_string($root)) {
			throw new \InvalidArgumentException('The pluralizer expects a string.');
		}

		if (!in_array(strtolower($root), $this->uncountable)) {
			// This check must be run before `checkIrregularForm` call
			if (!$this->isAmbiguousPlural($root)) {
				if (null !== $replacement = $this->checkIrregularForm($root, $this->irregular)) {
					$pluralForm = $replacement;
				} elseif (null !== $replacement = $this->checkIrregularSuffix($root, $this->plural)) {
					$pluralForm = $replacement;
				} elseif (!$this->isPlural($root)) {
					// fallback to naive pluralization
					$pluralForm = $root . 's';
				}
			}
		}

		return $pluralForm;
	}
393572
public static function generate_options($root = null)
	{
		if ($root === null)
		{
			$root = static::query()
				->where('id', 1)
				->get_one();
		}

		$return = [];

		if ($root)
		{
			foreach ($root->children()->get() as $model)
			{
				if ($model->has_children())
				{
					$return[$model->name] = static::generate_options($model);
				}
				else
				{
					$return[$model->id] = $model->name;
				}
			}
		}

		return $return;
	}
491648
public static function pluralize( $word ) {
		if ( isset( self::$cache['pluralize'][ $word ] ) ) {
			return self::$cache['pluralize'][ $word ];
		}

		if ( ! isset( self::$plural['merged']['irregular'] ) ) {
			self::$plural['merged']['irregular'] = self::$plural['irregular'];
		}

		if ( ! isset( self::$plural['merged']['uninflected'] ) ) {
			self::$plural['merged']['uninflected'] = array_merge( self::$plural['uninflected'], self::$uninflected );
		}

		if ( ! isset( self::$plural['cacheUninflected'] ) || ! isset( self::$plural['cacheIrregular'] ) ) {
			self::$plural['cacheUninflected'] = '(?:' . implode( '|', self::$plural['merged']['uninflected'] ) . ')';
			self::$plural['cacheIrregular']   = '(?:' . implode( '|', array_keys( self::$plural['merged']['irregular'] ) ) . ')';
		}

		if ( preg_match( '/(.*)\\b(' . self::$plural['cacheIrregular'] . ')$/i', $word, $regs ) ) {
			self::$cache['pluralize'][ $word ] = $regs[1] . substr( $word, 0, 1 ) . substr( self::$plural['merged']['irregular'][ strtolower( $regs[2] ) ], 1 );

			return self::$cache['pluralize'][ $word ];
		}

		if ( preg_match( '/^(' . self::$plural['cacheUninflected'] . ')$/i', $word, $regs ) ) {
			self::$cache['pluralize'][ $word ] = $word;

			return $word;
		}

		foreach ( self::$plural['rules'] as $rule => $replacement ) {
			if ( preg_match( $rule, $word ) ) {
				self::$cache['pluralize'][ $word ] = preg_replace( $rule, $replacement, $word );

				return self::$cache['pluralize'][ $word ];
			}
		}
	}
1000099
public static function lookupByName($name)
    {
        if (empty($name)) {
            throw new \InvalidArgumentException('Argument "name" cannot be empty');
        }

        if (!isset(self::$methods_config[$name])) {
            throw new \InvalidArgumentException('Method "' . $name . '" doesn\'t exist');
        }

        return self::$methods_config[$name];
    }
1277039
public function setUsername($username)
    {
        if (preg_match(self::PATTERN_MATCH_USERNAME, $username) !== 1) {
            throw new \InvalidArgumentException('"' . $username . '" is not a valid username.', 1184071238);
        }

        $this->username = $username;
    }
183364
public static function pluralize($input) {
		if (self::$pluralizer === null) {
			self::$pluralizer = new StandardEnglishSingularizer();
		}

		return self::$pluralizer->getPluralForm($input);
	}
1146962
public function absolute($root = null)
    {
        //argument 1 must be a string or null
        Argument::i()->test(1, 'string', 'null');

        //if path is a directory or file
        if (is_dir($this->data) || is_file($this->data)) {
            return $this;
        }

        //if root is null
        if (is_null($root)) {
            //assume the root is doc root
            $root = $_SERVER['DOCUMENT_ROOT'];
        }

        //get the absolute path
        $absolute = $this->format($this->format($root).$this->data);

        //if absolute is a directory or file
        if (is_dir($absolute) || is_file($absolute)) {
            $this->data = $absolute;
            return $this;
        }

        //if we are here then it means that no path was found so we should throw an exception
        Exception::i()
            ->setMessage(self::ERROR_FULL_PATH_NOT_FOUND)
            ->addVariable($this->data)
            ->addVariable($absolute)
            ->trigger();
    }
62018
private function checkIrregularSuffix($root, $irregular) {
		foreach ($irregular as $pattern => $result) {
			$searchPattern = '/' . $pattern . '$/i';
			if ($root !== $replacement = preg_replace($searchPattern, $result, $root)) {
				return $replacement;
			}
		}

		return null;
	}
292927
protected function resolveCallbacksForRoot(array $root)
    {
        if (isset($root['accessControl'])) {
            $callable = $root['accessControl'];
            if (!is_callable($callable) && is_string($callable)) {
                $root['accessControl'] = $this->resolveCallable($callable);
            }
        }

        return $root;
    }
1091125
public static function translate_plural($string, Translation $translation = null) {
		if ($translation !== null) {
			$translation = self::get($translation->language, $translation->application_name);
		} else {
			$translation = self::get();
		}

		return $translation->translate_string($string);
	}
499503
protected function findRoot($root)
    {
        // Empty root will set the path to assets
        if (!$root) {
            throw new \InvalidArgumentException("Missing argument for root path");
        }

        // Substitute leading ./ with BASE_PATH
        if (strpos($root, './') === 0) {
            return BASE_PATH . substr($root, 1);
        }

        // Substitute leading ./ with parent of BASE_PATH, in case storage is outside of the webroot.
        if (strpos($root, '../') === 0) {
            return dirname(BASE_PATH) . substr($root, 2);
        }

        return $root;
    }
56496
private function formatName(PuliResource $resource)
    {
        $name = $resource->getName();

        if ($resource->hasChildren()) {
            return '<c1>'.$name.'</c1>';
        }

        return $name;
    }
1095868
public function getPluralForm($root)
    {
        // save some time in the case that singular and plural are the same
        if (in_array(strtolower($root), $this->_uncountable)) {
            return $root;
        }

        // check for irregular singular words
        foreach ($this->_irregular as $pattern => $result) {
            $searchPattern = '/' . $pattern . '$/i';
            if (preg_match($searchPattern, $root)) {
                $replacement = preg_replace($searchPattern, $result, $root);
                // look at the first char and see if it's upper case
                // I know it won't handle more than one upper case char here (but I'm OK with that)
                if (preg_match('/^[A-Z]/', $root)) {
                    $replacement = ucfirst($replacement);
                }

                return $replacement;
            }
        }

        // check for irregular singular suffixes
        foreach ($this->_plural as $pattern => $result) {
            $searchPattern = '/' . $pattern . '$/i';
            if (preg_match($searchPattern, $root)) {
                return preg_replace($searchPattern, $result, $root);
            }
        }

        // fallback to naive pluralization
        return $root . 's';
    }
172787
public static function pluralize($word) {
        foreach(self::$_exceptions as $exception) {
			if($exception['singular'] == $word){
				return $exception['plural'];
			}
        }

        return parent::pluralize($word);
	}
97530
public function getSet($root)
    {
        $filters = $this->getQueryFilters();
        $filters['where'] = array($this->_child_key => $root);

        $options = array(
            'repository' => $this->getChildRepository(),
            'query' => $filters,
            'root' => $root,
            'property' => $this->_child_key,
        );

        $set = AnService::get('anahita:domain.entityset.decorator.onetomany', $options);

        return $set;
    }
284427
protected static function name(string $key): string
    {
        if (!isset(static::$names[$key]))
        {
            static::$names[$key] = Flow::VERSION . \sha1($key);
        }

        return static::$names[$key];
    }
881914
public static function pluralise($word)
    {
        // Run each rule over the word
        foreach (static::$pluralRules as $rule => $replacement) {
            if (preg_match($rule, $word)) {
                return preg_replace($rule, $replacement, $word);
            }
        }

        return $word;
    }