How to set and get cookie in Magento 2?

Magento 2 You can add/set cookies and get/retrieve the cookie using Magento\Framework\Stdlib\CookieManagerInterface Interface.

By default, You can set the cookie using $_COOKIE with native PHP.

When you are following the coding standard in Magento 2, PHPMd displays the error for $_COOKIE is discouraged in Magento 2.

Write Unit test for InputException Error Test in Magento 2.

You can write a  Unit test to check the InputException error text message matched or not using assertEquals() or assertStringMatchesFormat() method for an input exception error.

Let’s take a simple example with a function,

How to Ignore Line exceeds maximum limit of characters PHP_CodeSniffer in Magento 2?

You can suppress the warning of PHP Code sniffer either by
phpcs:ignore or phpcs:disable and phpcs:enable.

Warning,  Line exceeds the maximum limit of 120 characters; contains 230 characters