/** * eg. 'Collection/Content/ResourceCollection' => 'Content/Resource' * eg. 'Entity/Content/ResourceEntity' => 'Content/Resource' */ public static final function getModelPath($model_class_name, $delimiter = '\\') { Kit::ensureString($model_class_name); Kit::ensureString($delimiter); $handler_prefix = self::getHandlerPrefixFromPath($model_class_name); // 'Resource' $word_list = Kit::split($delimiter, $model_class_name); while (Kit::len($word_list) > 0 and 'Model' !== $word_list[0]) { $word_list = Kit::slice($word_list, 1); } $word_list = Kit::slice($word_list, 2); // [ 'Content', 'ResourceCollection' ] Kit::popList($word_list); // [ 'Content' ] $word_list[] = $handler_prefix; // [ 'Content', 'Resource' ] return Kit::join('/', $word_list); // 'Content/Resource' }
public static final function toTimestamp(MongoDate $mongo_date) { $result = Kit::split(' ', $mongo_date->__toString()); return (int) $result[1] + (double) $result[0]; }