Home PHP Libraries Other libraries Lightweight tag parsing PHP library
Lightweight tag parsing PHP library

As we all know, there are many ways to parse tags. Today we will bring a PHP library that uses lightweight tags to parse, let’s take a look.

<?php
namespace Decoda;
use Decoda\Decoda;
use Decoda\Loader\FileLoader;
use Decoda\Test\TestCase;
use Decoda\Test\TestComponent;
class ComponentTest extends TestCase {
    protected function setUp() {
        parent::setUp();
        $this->object = new TestComponent(array('key' => 'value'));
    }
    public function testAddGetLoaders() {
        $this->assertEquals(0, count($this->object->getLoaders()));
        $this->object->addLoader(new FileLoader(TEST_DIR . '/config/test.php'));
        $this->assertEquals(1, count($this->object->getLoaders()));
    }
    public function testGetSetConfig() {
        $this->assertEquals('value', $this->object->getConfig('key'));
        $this->assertEquals(null, $this->object->getConfig('foobar'));
        $this->object->setConfig(array('key' => 'foo'));
        $this->assertEquals('foo', $this->object->getConfig('key'));
    }
    public function testGetSetParser() {
        $this->assertEquals(null, $this->object->getParser());
        $this->object->setParser(new Decoda());
        $this->assertInstanceOf('Decoda\Decoda', $this->object->getParser());
    }
    public function testMessage() {
        $this->object->setParser(new Decoda());
        $this->assertEquals('Quote by {author}', $this->object->message('quoteBy'));
    }
}


Disclaimer

All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn

Related Article

PHP parsing html class library simple_html_dom PHP parsing html class library simple_html_dom

08 Aug 2016

:This article mainly introduces the PHP parsing HTML class library simple_html_dom. Students who are interested in PHP tutorials can refer to it.

Parsing the PHP standard library SPL data structure Parsing the PHP standard library SPL data structure

30 Sep 2020

The php column analyzes the SPL data structure of the PHP standard library for everyone.

Several tag parsing of PHP scripts_PHP tutorial Several tag parsing of PHP scripts_PHP tutorial

15 Jul 2016

Several tag parsing for PHP scripts. What we want to introduce to you today is about 1. There are four types of tags in PHP scripts: short tags and asp tags are convenient but have poor portability and distribution, and are generally not recommended. Also note that if you add PHP

Lithe Events: A Lightweight and Powerful Event Handling Library for PHP Lithe Events: A Lightweight and Powerful Event Handling Library for PHP

16 Dec 2024

Lithe Events is a lightweight yet powerful library for event management in PHP applications. It allows you to easily create, register, emit, and remove events, creating a decoupled and flexible architecture. This detailed guide will walk you through

PHP-ExcelReader: PHP class library for parsing excel files_PHP tutorial PHP-ExcelReader: PHP class library for parsing excel files_PHP tutorial

13 Jul 2016

PHP-ExcelReader: PHP class library for parsing excel files. PHP-ExcelReader: PHP class library for parsing excel files. PHP-ExcelReader is an open source project based on PHP. Its function is to parse excel files. The official website of PHP-ExcelReader is as follows:

PHP parsing html class library simple_html_dom transcoding bug_PHP tutorial PHP parsing html class library simple_html_dom transcoding bug_PHP tutorial

13 Jul 2016

PHP parsing html class library simple_html_dom transcoding bug. I have been using simple_html_dom to capture some articles these days. The encoding of different websites in China is basically gbk gb2312 utf-8. Most of them are gb2312 and utf-8. My version of simple_html_dom has a method

See all articles