Skip to content

Commit

Permalink
Updated README files.
Browse files Browse the repository at this point in the history
  • Loading branch information
vinogradsoft committed Dec 2, 2023
1 parent 0ce37c0 commit e159389
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 36 deletions.
53 changes: 36 additions & 17 deletions README-ru_RU.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
<div align="center">
<img alt="Compass logo" src="banner.svg">
<br/><br/>
</div>
<br/><br/>
<div align="center">
<strong>Создавайте повторно используемые приложения.</strong>
<br>
Библиотека с открытым исходным кодом.
<br /><br />
</div>

<div align="center">

[![codecov](https://codecov.io/gh/vinogradsoft/compass/graph/badge.svg?token=S1XRZ1GEY8)](https://codecov.io/gh/vinogradsoft/compass)
# Compass
<img src="https://badgen.net/static/license/MIT/green">

</div>

> Compass - это библиотека, предназначенная для работы с URL-адресами и путями к файлам на жестком диске. В ее состав
## Что такое Compass?

> 👉 Compass - это библиотека, предназначенная для работы с URL-адресами и путями к файлам на жестком диске. В ее состав
> входят инструменты для упрощения манипуляций с этими данными. Цель библиотеки - облегчить работу с URL-адресами и
> данными о расположении файлов.
Expand Down Expand Up @@ -31,7 +49,7 @@ php composer require vinogradsoft/compass "^1.0"

## Компонент URL

### Быстрый старт
### 🚀 Быстрый старт

```php
<?php
Expand Down Expand Up @@ -90,21 +108,21 @@ echo '<br><br><b>new URL:</b> ',$url; #http://xn--h1alffa9f.xn--p1ai
- метода `$url->setAll(array $parts);`
- методов отвечающих за конкретную часть Url (как показано в быстром старте).

### Примеры
### Примеры

#### **Через конструктор**
#### **👉 Через конструктор**

```php
$url = new Url('http://grigor:[email protected]:8080/path/to/resource?query=value#fragment');
```

#### **С помощью метода `$url->setSource(string $src);`**
#### **👉 С помощью метода `$url->setSource(string $src);`**

```php
$url->setSource('http://grigor:[email protected]:8080/path/to/resource?query=value#fragment');
```

#### **С помощью метода `$url->setAll(array $parts);`**
#### **👉 С помощью метода `$url->setAll(array $parts);`**

```php
$url->setAll([
Expand All @@ -120,7 +138,7 @@ $url->setAll([
]);
```

#### **С помощью методов отвечающих за конкретную часть Url.**
#### **👉 С помощью методов отвечающих за конкретную часть Url.**

```php
$url->setScheme('http')->setUser('grigor')->setPassword('password')->setHost('vinograd.soft')
Expand All @@ -131,7 +149,7 @@ $url->setScheme('http')->setUser('grigor')->setPassword('password')->setHost('vi
В первых двух вариантах суффикс не распознается. В таких случаях суффикс необходимо установить отдельным методом
`$url->setSuffix(.json);`, только так вы сможете им управлять.

> Суффикс не анализируется, так как он может быть любой строкой, и не обязательно начинаться с точки. Если вы передаете
> Суффикс не анализируется, так как он может быть любой строкой, и не обязательно начинаться с точки. Если вы передаете
> URL с суффиксом, то он становится частью path.
### Применение изменений
Expand All @@ -146,7 +164,7 @@ $url->setScheme('http')->setUser('grigor')->setPassword('password')->setHost('vi

### Стратегии обновления

> ***Стратегия обновления*** - это объект, который объединяет все входные данные для создания итогового URL-адреса.
> 📢 ***Стратегия обновления*** - это объект, который объединяет все входные данные для создания итогового URL-адреса.
> Этот объект должен быть реализацией интерфейса `Compass\UrlStrategy`. В системе, класс, который выполняет эту функцию,
> называется `Compass\DefaultUrlStrategy`. <br>
Expand All @@ -172,7 +190,7 @@ $url->setScheme('http')->setUser('grigor')->setPassword('password')->setHost('vi
участок для которого был передан параметр. После вызова метода `$url->updateSource();` в работу включаются
соответствующие методы стратегии.

> Важно запомнить, что в объекте `Compass\Url` хранятся исходные части, которые передал пользователь и результаты работы
> Важно запомнить, что в объекте `Compass\Url` хранятся исходные части, которые передал пользователь и результаты работы
> каждого метода стратегии.
Выполнение методов можно поделить условно на три уровня.
Expand Down Expand Up @@ -233,7 +251,7 @@ $relativeUrlState &= ~Url::QUERY_STATE;
Остальными участками можно манипулировать аналогичным способом, исключением является только `$schemeState` ему нужно
присвоить булево значение.

### Пример создания своей стратегии
### Пример создания своей стратегии

При построении своего процесса обновления URL, иногда требуется, чтобы выполнился метод который на основе текущего
состояния не выполниться. В таких случаях используется дополнительный метод `forceUnlockMethod(...)` в котором можно
Expand Down Expand Up @@ -322,11 +340,11 @@ src и другие атрибуты этого типа).

## Компонент PATH

`Compass\Path` можно охарактеризовать как объектное представление пути к файлу. Он оперирует строкой пути не
👉 `Compass\Path` можно охарактеризовать как объектное представление пути к файлу. Он оперирует строкой пути не
опираясь на реальную файловую систему. Компонент так же как и `Compass\Url` имеет стратегию обновления, которая включает
в себя один метод `updatePath()`. Важно отметить, что этот компонент не имеет состояний.

### Демонстрация методов
### 🚀 Демонстрация методов

```php
<?php
Expand Down Expand Up @@ -381,9 +399,10 @@ echo '<br>', $path->getLast(); # file.v

``` php composer tests ```

## Содействие

### Содействие
Пожалуйста, смотрите [ВКЛАД](CONTRIBUTING.md) для получения подробной информации.

### Лицензия
Лицензия MIT (MIT). Пожалуйста, смотрите [файл лицензии](LICENSE) для получения дополнительной информации.
## Лицензия

Лицензия MIT (MIT). Пожалуйста, смотрите [файл лицензии](LICENSE) для получения дополнительной информации.
55 changes: 36 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
<div align="center">
<img alt="Compass logo" src="banner.svg">
<br/><br/>
</div>
<br/><br/>
<div align="center">
<strong>Create reusable applications.</strong>
<br>
Open source library.
<br /><br />
</div>

<div align="center">

[![codecov](https://codecov.io/gh/vinogradsoft/compass/graph/badge.svg?token=S1XRZ1GEY8)](https://codecov.io/gh/vinogradsoft/compass)
# Compass
<img src="https://badgen.net/static/license/MIT/green">

</div>

## What is Compass?

> Compass is a library designed to work with URLs and hard disk file paths. It includes tools to simplify manipulation
> 👉 Compass is a library designed to work with URLs and hard disk file paths. It includes tools to simplify manipulation
> of this data. The goal of the library is to facilitate working with URLs and data on file locations.
## General information
## General Information

Compass can be used in various PHP applications to process file paths and URLs. It includes two main components:
`Compass\Path` and `Compass\Url`. Both of these components are separate objects and offer a set of methods for simple
Expand All @@ -27,7 +45,7 @@ Requires PHP 8.0 or newer.

## URL Component

### Quick Start
### 🚀 Quick Start

```php
<?php
Expand Down Expand Up @@ -86,21 +104,21 @@ Parameters can be set using:
- the `setAll` method
- methods specific to a particular part of the URL (as shown in the quick start).

### Examples
### Examples

#### **Through the constructor**
#### **👉 Through the constructor**

```php
$url = new Url('http://grigor:[email protected]:8080/path/to/resource?query=value#fragment');
```

#### **Using the `setSource` method**
#### **👉 Using the `setSource` method**

```php
$url->setSource('http://grigor:[email protected]:8080/path/to/resource?query=value#fragment');
```

#### **Using the `setAll` method**
#### **👉 Using the `setAll` method**

```php
$url->setAll([
Expand All @@ -116,7 +134,7 @@ $url->setAll([
]);
```

#### **Using methods responsible for a specific part of Url.**
#### **👉 Using methods responsible for a specific part of Url.**

```php
$url->setScheme('http')->setUser('grigor')->setPassword('password')->setHost('vinograd.soft')
Expand All @@ -127,7 +145,7 @@ $url->setScheme('http')->setUser('grigor')->setPassword('password')->setHost('vi
In the first two options the suffix is not recognized. In such cases, the suffix must be set using a
separate `$url->setSuffix(.json);` method, this is the only way you can manage it.

> The suffix is not parsed since it could be any string and does not have to start with a dot. If you pass a URL with a
> The suffix is not parsed since it could be any string and does not have to start with a dot. If you pass a URL with a
> suffix, it becomes part of the `path`.
### Applying Changes
Expand All @@ -142,7 +160,7 @@ After the parameters have been applied, you can get the updated result using the

### Upgrade Strategies

> An update strategy is an object that combines all inputs to create a final URL. This object must be an implementation
> 📢 An update strategy is an object that combines all inputs to create a final URL. This object must be an implementation
> of the `Compass\UrlStrategy` interface. In the system, the class that performs this function is called
> `Compass\DefaultUrlStrategy`.
Expand All @@ -168,7 +186,7 @@ By setting any parameter for a URL, the system changes the state of the section,
the parameter was passed. After calling the `$url->updateSource();` method Appropriate strategy methods are included in
the work.

> It is important to remember that the `Compass\Url` object stores the initial parts that the user installed and the
> It is important to remember that the `Compass\Url` object stores the initial parts that the user installed and the
> results of each strategy method.
The implementation of methods can be divided into three levels.
Expand Down Expand Up @@ -228,7 +246,7 @@ $relativeUrlState &= ~Url::QUERY_STATE;
The remaining sections can be manipulated in a similar way, with the exception of `$schemeState`, which needs to be
assigned a boolean value.

### An Example Of Creating Your Own Strategy
### An Example Of Creating Your Own Strategy

When building your URL update process, sometimes you want a method to be executed that, based on the current state, will
not be executed. In such cases, the additional method `forceUnlockMethod(...)` is used, in which you can change the
Expand Down Expand Up @@ -317,11 +335,11 @@ and other attributes of this type).

## PATH Component

`Compass\Path` can be described as an object representation of a file path. It operates on the path string without
👉 `Compass\Path` can be described as an object representation of a file path. It operates on the path string without
relying on the actual file system. The component, like `Compass\Url`, has an update strategy, which includes
one `updatePath()` method. It's important to note that this component is stateless.

### Demonstration Of Methods
### 🚀 Demonstration Of Methods

```php
<?php
Expand Down Expand Up @@ -376,11 +394,10 @@ echo '<br>', $path->getLast(); # file.v

``` php composer tests ```

### Contributing
## Contributing

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### License
## License

The MIT License (MIT). Please see License [File](LICENSE) for more
information.
The MIT License (MIT). Please see License [File](LICENSE) for more information.
Loading

0 comments on commit e159389

Please sign in to comment.