├── .github
├── ISSUE_TEMPLATE
│ ├── bug.yaml
│ ├── documentation.yaml
│ └── feature.yaml
└── workflows
│ ├── linter.yml
│ └── test.yml
├── .gitignore
├── .gitpod.yml
├── CODE_OF_CONDUCT.md
├── Contributing.md
├── LICENSE.md
├── README.md
├── composer.json
├── phpunit.xml
├── psalm.xml
├── src
└── AB
│ └── Test.php
└── tests
└── AB
└── TestTest.php
/.github/ISSUE_TEMPLATE/bug.yaml:
--------------------------------------------------------------------------------
1 | name: "🐛 Bug Report"
2 | description: "Submit a bug report to help us improve"
3 | title: "🐛 Bug Report: "
4 | labels: [bug]
5 | body:
6 | - type: markdown
7 | attributes:
8 | value: |
9 | Thanks for taking the time to fill out our bug report form 🙏
10 | - type: textarea
11 | id: steps-to-reproduce
12 | validations:
13 | required: true
14 | attributes:
15 | label: "👟 Reproduction steps"
16 | description: "How do you trigger this bug? Please walk us through it step by step."
17 | placeholder: "When I ..."
18 | - type: textarea
19 | id: expected-behavior
20 | validations:
21 | required: true
22 | attributes:
23 | label: "👍 Expected behavior"
24 | description: "What did you think would happen?"
25 | placeholder: "It should ..."
26 | - type: textarea
27 | id: actual-behavior
28 | validations:
29 | required: true
30 | attributes:
31 | label: "👎 Actual Behavior"
32 | description: "What did actually happen? Add screenshots, if applicable."
33 | placeholder: "It actually ..."
34 | - type: dropdown
35 | id: utopia-version
36 | attributes:
37 | label: "🎲 Utopia AB version"
38 | description: "What version of Appwrite are you running?"
39 | options:
40 | - Version 0.10.x
41 | - Version 0.9.x
42 | - Version 0.8.x
43 | - Version 0.7.x
44 | - Version 0.6.x
45 | - Different version (specify in environment)
46 | validations:
47 | required: true
48 | - type: dropdown
49 | id: php-version
50 | attributes:
51 | label: "🐘 PHP Version"
52 | description: "What version of PHP are you running?"
53 | options:
54 | - PHP 7.3.x
55 | - PHP 7.4.x
56 | - Different version (specify in environment)
57 | validations:
58 | required: true
59 | - type: dropdown
60 | id: operating-system
61 | attributes:
62 | label: "💻 Operating system"
63 | description: "What OS is your server / device running on?"
64 | options:
65 | - Linux
66 | - MacOS
67 | - Windows
68 | - Something else
69 | validations:
70 | required: true
71 | - type: textarea
72 | id: enviromnemt
73 | validations:
74 | required: false
75 | attributes:
76 | label: "🧱 Your Environment"
77 | description: "Is your environment customized in any way?"
78 | placeholder: "I use Cloudflare for ..."
79 | - type: checkboxes
80 | id: no-duplicate-issues
81 | attributes:
82 | label: "👀 Have you spent some time to check if this issue has been raised before?"
83 | description: "Have you Googled for a similar issue or checked our older issues for a similar bug?"
84 | options:
85 | - label: "I checked and didn't find similar issue"
86 | required: true
87 | - type: checkboxes
88 | id: read-code-of-conduct
89 | attributes:
90 | label: "🏢 Have you read the Code of Conduct?"
91 | options:
92 | - label: "I have read the [Code of Conduct](https://github.com/appwrite/appwrite/blob/HEAD/CODE_OF_CONDUCT.md)"
93 | required: true
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/documentation.yaml:
--------------------------------------------------------------------------------
1 | name: "📚 Documentation"
2 | description: "Report an issue related to documentation"
3 | title: "📚 Documentation: "
4 | labels: [documentation]
5 | body:
6 | - type: markdown
7 | attributes:
8 | value: |
9 | Thanks for taking the time to fill out our documentation update request form 🙏
10 | - type: textarea
11 | id: issue-description
12 | validations:
13 | required: true
14 | attributes:
15 | label: "💭 Description"
16 | description: "A clear and concise description of what the issue is."
17 | placeholder: "Documentation should not ..."
18 | - type: checkboxes
19 | id: no-duplicate-issues
20 | attributes:
21 | label: "👀 Have you spent some time to check if this issue has been raised before?"
22 | description: "Have you Googled for a similar issue or checked our older issues for a similar bug?"
23 | options:
24 | - label: "I checked and didn't find similar issue"
25 | required: true
26 | - type: checkboxes
27 | id: read-code-of-conduct
28 | attributes:
29 | label: "🏢 Have you read the Code of Conduct?"
30 | options:
31 | - label: "I have read the [Code of Conduct](https://github.com/appwrite/appwrite/blob/HEAD/CODE_OF_CONDUCT.md)"
32 | required: true
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature.yaml:
--------------------------------------------------------------------------------
1 | name: 🚀 Feature
2 | description: "Submit a proposal for a new feature"
3 | title: "🚀 Feature: "
4 | labels: [feature]
5 | body:
6 | - type: markdown
7 | attributes:
8 | value: |
9 | Thanks for taking the time to fill out our feature request form 🙏
10 | - type: textarea
11 | id: feature-description
12 | validations:
13 | required: true
14 | attributes:
15 | label: "🔖 Feature description"
16 | description: "A clear and concise description of what the feature is."
17 | placeholder: "You should add ..."
18 | - type: textarea
19 | id: pitch
20 | validations:
21 | required: true
22 | attributes:
23 | label: "🎤 Pitch"
24 | description: "Please explain why this feature should be implemented and how it would be used. Add examples, if applicable."
25 | placeholder: "In my use-case, ..."
26 | - type: checkboxes
27 | id: no-duplicate-issues
28 | attributes:
29 | label: "👀 Have you spent some time to check if this issue has been raised before?"
30 | description: "Have you Googled for a similar issue or checked our older issues for a similar bug?"
31 | options:
32 | - label: "I checked and didn't find similar issue"
33 | required: true
34 | - type: checkboxes
35 | id: read-code-of-conduct
36 | attributes:
37 | label: "🏢 Have you read the Code of Conduct?"
38 | options:
39 | - label: "I have read the [Code of Conduct](https://github.com/appwrite/appwrite/blob/HEAD/CODE_OF_CONDUCT.md)"
40 | required: true
--------------------------------------------------------------------------------
/.github/workflows/linter.yml:
--------------------------------------------------------------------------------
1 | name: "Linter"
2 |
3 | on: [pull_request]
4 | jobs:
5 | lint:
6 | name: Linter
7 | runs-on: ubuntu-latest
8 |
9 | steps:
10 | - name: Checkout repository
11 | uses: actions/checkout@v3
12 | with:
13 | fetch-depth: 2
14 |
15 | - run: git checkout HEAD^2
16 |
17 | - name: Run Linter
18 | run: |
19 | docker run --rm -v $PWD:/app composer sh -c \
20 | "composer install --profile --ignore-platform-reqs && composer lint"
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: "Tests"
2 |
3 | on: [pull_request,push]
4 |
5 |
6 | jobs:
7 | test:
8 | name: "Unit & E2E Test"
9 | runs-on: ubuntu-latest
10 | steps:
11 | - name: Checkout repository
12 | uses: actions/checkout@v3
13 | with:
14 | fetch-depth: 2
15 | - name: Run Tests
16 | run: |
17 | docker run --rm --interactive -v $PWD:/app composer sh -c \
18 | "composer install --profile --ignore-platform-reqs && composer test"
19 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | composer.lock
2 | /vendor/
3 | /.idea/
--------------------------------------------------------------------------------
/.gitpod.yml:
--------------------------------------------------------------------------------
1 | tasks:
2 | - name: PHP preparations
3 | init: |
4 | composer install --ignore-platform-reqs
5 |
6 | vscode:
7 | extensions:
8 | - ms-azuretools.vscode-docker
9 | - zobo.php-intellisense
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to make participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity, expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | - Using welcoming and inclusive language
18 | - Being respectful of differing viewpoints and experiences
19 | - Gracefully accepting constructive criticism
20 | - Focusing on what is best for the community
21 | - Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | - The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | - Trolling, insulting/derogatory comments, and personal or political attacks
28 | - Public or private harassment
29 | - Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | - Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at team@appwrite.io. All complaints will
59 | be reviewed and investigated and will result in a response that is deemed
60 | necessary and appropriate to the circumstances. The project team is obligated
61 | to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see
76 | https://www.contributor-covenant.org/faq
77 |
--------------------------------------------------------------------------------
/Contributing.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | We would ❤️ for you to contribute to Utopia-php and help make it better! We want contributing to Utopia-php to be fun, enjoyable, and educational for anyone and everyone. All contributions are welcome, including issues, new docs as well as updates and tweaks, blog posts, workshops, and more.
4 |
5 | ## How to Start?
6 |
7 | If you are worried or don’t know where to start, check out our next section explaining what kind of help we could use and where can you get involved. You can reach out with questions to [Eldad Fux (@eldadfux)](https://twitter.com/eldadfux) or anyone from the [Appwrite team on Discord](https://discord.gg/GSeTUeA). You can also submit an issue, and a maintainer can guide you!
8 |
9 | ## Code of Conduct
10 |
11 | Help us keep Utopia-php open and inclusive. Please read and follow our [Code of Conduct](/CODE_OF_CONDUCT.md).
12 |
13 | ## Submit a Pull Request 🚀
14 |
15 | Branch naming convention is as following
16 |
17 | `TYPE-ISSUE_ID-DESCRIPTION`
18 |
19 | example:
20 |
21 | ```
22 | doc-548-submit-a-pull-request-section-to-contribution-guide
23 | ```
24 |
25 | When `TYPE` can be:
26 |
27 | - **feat** - is a new feature
28 | - **doc** - documentation only changes
29 | - **cicd** - changes related to CI/CD system
30 | - **fix** - a bug fix
31 | - **refactor** - code change that neither fixes a bug nor adds a feature
32 |
33 | **All PRs must include a commit message with the changes description!**
34 |
35 | For the initial start, fork the project and use git clone command to download the repository to your computer. A standard procedure for working on an issue would be to:
36 |
37 | 1. `git pull`, before creating a new branch, pull the changes from upstream. Your master needs to be up to date.
38 |
39 | ```
40 | $ git pull
41 | ```
42 |
43 | 2. Create new branch from `master` like: `doc-548-submit-a-pull-request-section-to-contribution-guide`
44 |
45 | ```
46 | $ git checkout -b [name_of_your_new_branch]
47 | ```
48 |
49 | 3. Work - commit - repeat ( be sure to be in your branch )
50 |
51 | 4. Push changes to GitHub
52 |
53 | ```
54 | $ git push origin [name_of_your_new_branch]
55 | ```
56 |
57 | 5. Submit your changes for review
58 | If you go to your repository on GitHub, you'll see a `Compare & pull request` button. Click on that button.
59 | 6. Start a Pull Request
60 | Now submit the pull request and click on `Create pull request`.
61 | 7. Get a code review approval/reject
62 | 8. After approval, merge your PR
63 | 9. GitHub will automatically delete the branch after the merge is done. (they can still be restored).
64 |
65 | ## Introducing New Features
66 |
67 | We would 💖 you to contribute to Utopia-php, but we would also like to make sure Utopia-php is as great as possible and loyal to its vision and mission statement 🙏.
68 |
69 | For us to find the right balance, please open an issue explaining your ideas before introducing a new pull request.
70 |
71 | This will allow the Utopia-php community to have sufficient discussion about the new feature value and how it fits in the product roadmap and vision.
72 |
73 | This is also important for the Utopia-php lead developers to be able to give technical input and different emphasis regarding the feature design and architecture. Some bigger features might need to go through our [RFC process](https://github.com/appwrite/rfc).
74 |
75 | ## Other Ways to Help
76 |
77 | Pull requests are great, but there are many other areas where you can help Utopia-php.
78 |
79 | ### Blogging & Speaking
80 |
81 | Blogging, speaking about, or creating tutorials about one of Utopia-php’s many features is great way to contribute and help our project grow.
82 |
83 | ### Presenting at Meetups
84 |
85 | Presenting at meetups and conferences about your Utopia-php projects. Your unique challenges and successes in building things with Utopia-php can provide great speaking material. We’d love to review your talk abstract/CFP, so get in touch with us if you’d like some help!
86 |
87 | ### Sending Feedbacks & Reporting Bugs
88 |
89 | Sending feedback is a great way for us to understand your different use cases of Utopia-php better. If you had any issues, bugs, or want to share about your experience, feel free to do so on our GitHub issues page or at our [Discord channel](https://discord.gg/GSeTUeA).
90 |
91 | ### Submitting New Ideas
92 |
93 | If you think Utopia-php could use a new feature, please open an issue on our GitHub repository, stating as much information as you can think about your new idea and it's implications. We would also use this issue to gather more information, get more feedback from the community, and have a proper discussion about the new feature.
94 |
95 | ### Improving Documentation
96 |
97 | Submitting documentation updates, enhancements, designs, or bug fixes. Spelling or grammar fixes will be very much appreciated.
98 |
99 | ### Helping Someone
100 |
101 | Searching for Utopia-php, GitHub or StackOverflow and helping someone else who needs help. You can also help by teaching others how to contribute to Utopia-php's repo!
102 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2013 Eldad Fux
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Utopia AB Tests
2 |
3 | [](https://travis-ci.com/utopia-php/ab)
4 | 
5 | [](https://appwrite.io/discord)
6 |
7 | Utopia AB Tests library is simple and lite library for managing AB tests on the server side. This library is aiming to be as simple and easy to learn and use. This library is maintained by the [Appwrite team](https://appwrite.io).
8 |
9 | Although this library is part of the [Utopia Framework](https://github.com/utopia-php/framework) project it is dependency free and can be used as standalone with any other PHP project or framework.
10 |
11 | ## Getting Started
12 |
13 | Install using composer:
14 | ```bash
15 | composer require utopia-php/ab
16 | ```
17 |
18 | ```php
19 | variation('title1', 'Hello World', 40) // 40% probability
29 | ->variation('title2', 'Foo Bar', 30) // 30% probability
30 | ->variation('title3', function () { // 30% probability
31 | return 'Title from a callback function';
32 | }, 30)
33 | ;
34 |
35 | $debug = [];
36 |
37 | for($i=0; $i<10000; $i++) {
38 | $debug[$test->run()]++;
39 | }
40 |
41 | var_dump($debug);
42 |
43 | ```
44 |
45 | If no probability value is passed to the variation, all variations with no probability values will be given equal values from the remaining 100% of the test variations.
46 |
47 | When passing a closure as value for your variation the callback will be executed only once the test is being run using the Test::run() method.
48 |
49 | ## System Requirements
50 |
51 | Utopia Framework requires PHP 7.4 or later. We recommend using the latest PHP version whenever possible.
52 |
53 | ## Copyright and license
54 |
55 | The MIT License (MIT) [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php)
56 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "utopia-php/ab",
3 | "description": "A simple AB Test library to manage server side AB testing",
4 | "type": "library",
5 | "keywords": ["php","framework", "upf", "utopia", "ab", "ab test", "ab testing", "ab tests"],
6 | "license": "MIT",
7 | "autoload": {
8 | "psr-4": {"Utopia\\AB\\": "src/AB"}
9 | },
10 | "scripts": {
11 | "lint": "./vendor/bin/pint --test",
12 | "format": "./vendor/bin/pint",
13 | "test": "./vendor/bin/phpunit --configuration phpunit.xml"
14 | },
15 | "require": {
16 | "php": ">=7.4"
17 | },
18 | "require-dev": {
19 | "phpunit/phpunit": "^9.3",
20 | "vimeo/psalm": "4.0.1",
21 | "laravel/pint": "1.2.*"
22 | },
23 | "minimum-stability": "dev"
24 | }
25 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 | ./tests/
14 |
15 |
16 |
--------------------------------------------------------------------------------
/psalm.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/AB/Test.php:
--------------------------------------------------------------------------------
1 | name = $name;
51 | }
52 |
53 | /**
54 | * Add a New Variation to Test
55 | *
56 | * @param mixed $value
57 | * @return $this
58 | */
59 | public function variation(string $name, $value, int $probability = null): self
60 | {
61 | $this->variations[$name] = $value;
62 | $this->probabilities[$name] = $probability;
63 |
64 | return $this;
65 | }
66 |
67 | /**
68 | * Run Test and Get Result
69 | *
70 | * @return mixed
71 | *
72 | * @throws Exception
73 | */
74 | public function run()
75 | {
76 | $result = $this->chance();
77 |
78 | $return = $this->variations[$result];
79 |
80 | if (\is_callable($return)) {
81 | $return = $return();
82 | }
83 |
84 | self::$results[$this->name] = $return;
85 |
86 | return $return;
87 | }
88 |
89 | /**
90 | * Get Random Variation Based on Probabilities Chance
91 | *
92 | *
93 | * @throws Exception
94 | */
95 | protected function chance(): string
96 | {
97 | $sum = 0;
98 | $empty = 0;
99 |
100 | foreach ($this->probabilities as $name => $value) {
101 | $sum += $value;
102 |
103 | if (empty($value)) {
104 | $empty++;
105 | }
106 | }
107 |
108 | if ($sum > 100) {
109 | throw new Exception('Test Error: Total variation probabilities is bigger than 100%');
110 | }
111 |
112 | if ($sum < 100) { // Auto set probability when it has no value
113 | foreach ($this->probabilities as $name => $value) {
114 | if (empty($value)) {
115 | $this->probabilities[$name] = (100 - $sum) / $empty;
116 | }
117 | }
118 | }
119 |
120 | $number = \rand(0, (int) \array_sum($this->probabilities) * 10);
121 | $starter = 0;
122 | $return = '';
123 |
124 | foreach ($this->probabilities as $key => $val) {
125 | $starter += $val * 10;
126 |
127 | if ($number <= $starter) {
128 | $return = $key;
129 | break;
130 | }
131 | }
132 |
133 | return $return;
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/tests/AB/TestTest.php:
--------------------------------------------------------------------------------
1 | test = new Test('unit-test');
18 | }
19 |
20 | public function tearDown(): void
21 | {
22 | $this->test = null;
23 | }
24 |
25 | public function testTest()
26 | {
27 | $this->test
28 | ->variation('title1', 'Title: Hello World', 40) // 40% probability
29 | ->variation('title2', 'Title: Foo Bar', 30) // 30% probability
30 | ->variation('title3', function () {
31 | return 'Title: Title from a callback function';
32 | }, 30); // 30% probability
33 |
34 | for ($i = 0; $i < 100; $i++) {
35 | $value = $this->test->run();
36 |
37 | $this->assertStringStartsWith('Title:', $value);
38 | }
39 |
40 | $this->test
41 | ->variation('title1', 'Title: Hello World', 100) // 100% probability
42 | ->variation('title2', 'Title: Foo Bar', 0) // 0% probability
43 | ->variation('title3', function () {
44 | return 'Title: Title from a callback function';
45 | }, 0); // 0% probability
46 |
47 | for ($i = 0; $i < 100; $i++) {
48 | $value = $this->test->run();
49 |
50 | $this->assertEquals('Title: Hello World', $value);
51 | }
52 |
53 | $test = new Test('another-test');
54 |
55 | $test
56 | ->variation('option1', 'title1')
57 | ->variation('option2', 'title2')
58 | ->variation('option3', 'title3');
59 |
60 | $test->run();
61 |
62 | $results = Test::results();
63 |
64 | $this->assertArrayHasKey('unit-test', $results);
65 | $this->assertArrayHasKey('another-test', $results);
66 | }
67 | }
68 |
--------------------------------------------------------------------------------