Skip to content

Commit

Permalink
Version 2 development
Browse files Browse the repository at this point in the history
  • Loading branch information
ElGigi committed Mar 21, 2021
1 parent 7ad6186 commit 3f5b2e8
Show file tree
Hide file tree
Showing 48 changed files with 4,179 additions and 2,716 deletions.
6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
language: php
php:
- 7.1
- 7.2
- 7.3
- 7.4
- 8.0snapshot
- 8.0

before_install:
- sudo apt-get -qq update
Expand Down
20 changes: 17 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning] (http://semver.org/).
For change log format, use [Keep a Changelog] (http://keepachangelog.com/).

All notable changes to this project will be documented in this file. This project adheres
to [Semantic Versioning] (http://semver.org/). For change log format,
use [Keep a Changelog] (http://keepachangelog.com/).

## [2.0.0-alpha1] - 2021-03-22

### Added

- `HtmlSelector` class to init and manage relations
- `XpathSolver` class to solve a selector to xpath
- Extensions to add pseudo classes

### Changed

- Refactoring

## [1.0.0] - 2020-11-05

First version
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $ composer require berlioz/html-selector

### Dependencies

- **PHP** ^7.1 || ^8.0
- **PHP** ^8.0
- PHP libraries:
- **dom**
- **libxml**
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}
},
"require": {
"php": "^7.1 || ^8.0",
"php": "^8.0",
"ext-dom": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
Expand All @@ -29,6 +29,6 @@
},
"require-dev": {
"berlioz/http-message": "^1.0",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0"
"phpunit/phpunit": "^9.3"
}
}
17 changes: 10 additions & 7 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/bootstrap.php" colors="true">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="./tests/bootstrap.php"
colors="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Berlioz HTML Selector test suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
</phpunit>
113 changes: 113 additions & 0 deletions src/CssSelector/CssSelector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?php
/*
* This file is part of Berlioz framework.
*
* @license https://opensource.org/licenses/MIT MIT License
* @copyright 2021 Ronan GIRON
* @author Ronan GIRON <https://github.com/ElGigi>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code, to the root.
*/

declare(strict_types=1);

namespace Berlioz\HtmlSelector\CssSelector;

/**
* Class CssSelector.
*/
class CssSelector
{
protected ?NextCssSelector $next = null;

public function __construct(
protected string $selector,
protected ?string $type = null,
protected ?string $id = null,
protected array $classes = [],
protected array $attributes = [],
protected array $pseudoClasses = [],
) {
}

/**
* __toString() PHP magic method.
*
* @return string
*/
public function __toString(): string
{
return $this->selector;
}

/**
* Get type.
*
* @return string|null
*/
public function getType(): ?string
{
return $this->type;
}

/**
* Get id.
*
* @return string|null
*/
public function getId(): ?string
{
return $this->id;
}

/**
* Get classes.
*
* @return array
*/
public function getClasses(): array
{
return $this->classes;
}

/**
* Get attributes.
*
* @return array
*/
public function getAttributes(): array
{
return $this->attributes;
}

/**
* Get pseudo classes.
*
* @return array
*/
public function getPseudoClasses(): array
{
return $this->pseudoClasses;
}

/**
* Get next.
*
* @return NextCssSelector|null
*/
public function getNext(): ?NextCssSelector
{
return $this->next;
}

/**
* Set next.
*
* @param NextCssSelector|null $next
*/
public function setNext(?NextCssSelector $next): void
{
$this->next = $next;
}
}
Loading

0 comments on commit 3f5b2e8

Please sign in to comment.