当前位置: 首页>>代码示例>>PHP>>正文


PHP Path::toString方法代码示例

本文整理汇总了PHP中Path::toString方法的典型用法代码示例。如果您正苦于以下问题:PHP Path::toString方法的具体用法?PHP Path::toString怎么用?PHP Path::toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Path的用法示例。


在下文中一共展示了Path::toString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: continuePath

function continuePath($path, $destination, $lineName)
{
    $debug = true;
    outputDebug("algorithm.continuePath()", $debug);
    $currentStation = $path->getCurrentStation();
    $currentLine = $currentStation->getLine($lineName);
    $connections = $currentLine->getConnections();
    if ($debug) {
        echo "currentStation = " . $currentStation->getName() . " (" . $currentStation->getID() . ")<br/>\n";
        echo "currentLine = " . $currentLine->name . "<br/>\n";
        echo "continuePath() :: found " . count($connections) . " connections.<br/>\n";
    }
    $newPaths = array();
    foreach ($connections as $connection) {
        if ($connection->id == $path->getLastStation()->getID()) {
            continue;
        }
        // create a new segment from the connection
        outputDebug("connection->id = " . $connection->id, $debug);
        $nextStation = retrieveStation($connection->id);
        $visited = isVisited($nextStation, $path->visited);
        if ($visited) {
            if (count($connections) == 1) {
                // end of the line. no match.
                outputDebug("end of line.", $debug);
                $newPaths[] = new MetaPath("EOL", $path);
                return $newPaths;
            } else {
                // we only care to go in the forward direction
                outputDebug("continuePath() :: already visited.", $debug);
                continue;
            }
        }
        $lines = $currentStation->getOverlapLines($nextStation);
        $newPath = new Path($path, $nextStation, $currentLine, $connection);
        $pathDestination = $path->getDestination();
        if ($destination instanceof Station2 && $nextStation->getID() == $destination->getID()) {
            outputDebug("found match, creating completed path", $debug);
            $newPaths[] = new MetaPath("match", $newPath);
            continue;
        }
        if ($pathDestination instanceof Station2 && $nextStation->getID() == $pathDestination->getID()) {
            outputDebug("found path destination, creating completed path", $debug);
            $newPaths[] = new MetaPath("found", $newPath);
            continue;
        }
        outputDebug("adding path to list = " . $newPath->toString(), $debug);
        $newPaths[] = new MetaPath("continue", $newPath);
    }
    outputDebug("algorithm.continuePath() : DONE", $debug);
    return $newPaths;
}
开发者ID:abc2mit,项目名称:abc2mit.github.io,代码行数:52,代码来源:algorithm.php

示例2: testCreateFromParts

 public function testCreateFromParts()
 {
     $parts = ['foo', 'bar/baz', 'taz'];
     $phlibPath = new Path($parts);
     $this->assertEquals('foo/bar\\/baz/taz', $phlibPath->toString());
 }
开发者ID:phlib,项目名称:path,代码行数:6,代码来源:PathTest.php


注:本文中的Path::toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。