Ejemplo n.º 1
0
 /**
  * Finds alias for given FQCN.
  *
  * @return string
  */
 public function findAlias(FQCN $fqcn)
 {
     $rev = $this->getReversed();
     if (array_key_exists($fqcn->toString(), $rev)) {
         return $rev[$fqcn->toString()];
     }
     return $fqcn->toString();
 }
Ejemplo n.º 2
0
 public function addFQCN(FQCN $fqcn)
 {
     $this->fqcns[$fqcn->toString()] = $fqcn;
 }
Ejemplo n.º 3
0
        it('creates parts from array', function () {
            $parts = ['Some', 'Long', 'Parts'];
            $fqn = new FQCN('ClassName', $parts);
            $parts[] = 'ClassName';
            expect($fqn->getParts())->to->equal($parts);
        });
        it('FQCN with class name only', function () {
            $fqn = new FQN('ClassName');
            expect($fqn->getParts())->to->equal(['ClassName']);
        });
    });
    describe('->join()', function () {
        it('joins another FQCN', function () {
            $fqn = new FQCN('ClassName', 'Some\\Long\\Path');
            $join = new FQCN('AnotherName', 'Another\\Long\\Name');
            expect($fqn->join($join)->getParts())->to->equal(['Some', 'Long', 'Path', 'ClassName', 'Another', 'Long', 'Name', 'AnotherName']);
        });
        it('joins FQN', function () {
            $fqn = new FQCN('ClassName', 'Some\\Long\\Path\\Another');
            $join = new FQN('Another\\Long\\Name');
            expect($fqn->join($join)->getParts())->to->equal(['Some', 'Long', 'Path', 'Another', 'ClassName', 'Another', 'Long', 'Name']);
        });
    });
    describe('->toString()', function () {
        it('returns valid string', function () {
            $str = 'Some\\Long\\Path\\To\\Name';
            $fqn = new FQCN('ClassName', $str);
            expect($fqn->toString())->to->equal($str . '\\ClassName');
        });
    });
});